Skip to content

Instantly share code, notes, and snippets.

@clinuxrulz
Last active May 8, 2016 11:14
Show Gist options
  • Save clinuxrulz/0a56108f31bafa1452b7b38eba198285 to your computer and use it in GitHub Desktop.
Save clinuxrulz/0a56108f31bafa1452b7b38eba198285 to your computer and use it in GitHub Desktop.
Derive4J Stream experiment
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gmail.clinuxrulz.derive4j.test.stream;
/**
*
* @author clintonselke
*/
public abstract class ExistsSStreamF<A> {
public abstract <R> R apply(ForallSStreamF<A,R> f);
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gmail.clinuxrulz.derive4j.test.stream;
/**
*
* @author clintonselke
*/
public abstract class ForallSStreamF<A,R> {
public abstract <S> R apply(StreamF<A,S> s);
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gmail.clinuxrulz.derive4j.test.stream;
import org.derive4j.Data;
/**
*
* @author clintonselke
*/
@Data
public abstract class Step<A,S> {
public interface Cases<R,A,S> {
R Step(A a, S s);
}
public abstract <R> R match(Cases<R, A, S> cases);
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gmail.clinuxrulz.derive4j.test.stream;
import org.derive4j.Data;
/**
*
* @author clintonselke
*/
@Data
public abstract class Stream<A> {
public interface Cases<R,A> {
R Stream(ExistsSStreamF<A> c);
}
public abstract <R> R match(Cases<R, A> cases);
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package gmail.clinuxrulz.derive4j.test.stream;
import java.util.function.Function;
import org.derive4j.Data;
/**
*
* @author clintonselke
*/
@Data
public abstract class StreamF<A,S> {
public interface Cases<R,A,S> {
R StreamF(Function<S, Step<A, S>> stepper, S init);
}
public abstract <R> R match(Cases<R, A, S> cases);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment