Last active
July 11, 2018 12:12
-
-
Save clinuxrulz/21cad00a3c75b2395187ace02a6acb97 to your computer and use it in GitHub Desktop.
Incremental Function in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fp.ilc; | |
import fj.F2; | |
public class Delta<A,DA> { | |
private final F2<A,DA,A> _patch; | |
private final DA _change; | |
private Delta(F2<A,DA,A> patch, DA change) { | |
this._patch = patch; | |
this._change = change; | |
} | |
public F2<A, DA, A> patch() { | |
return _patch; | |
} | |
public DA change() { | |
return _change; | |
} | |
public A patch(A a) { | |
return patch().f(a, change()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fp.ilc; | |
import fp.inc_f.IncFCartesian; | |
import fp.inc_f.IncFCategory; | |
import fp.inc_f.IncFSemigroupoid; | |
import fp.kinds.__; | |
import fp.kinds.__2; | |
import fj.P2; | |
public interface IncF<A,B> extends __2<IncF.Mu,A,B> { | |
interface Mu {} | |
static <A,B> IncF<A,B> narrow(__<__<Mu,A>,B> a) { | |
return (IncF<A,B>)a; | |
} | |
P2<B,IncF2<A,B>> apply(A a); | |
static IncFSemigroupoid semigroupoid() { | |
return new IncFSemigroupoid() {}; | |
} | |
static IncFCategory category() { | |
return new IncFCategory() {}; | |
} | |
static <U> IncFCartesian<U> cartesian() { | |
return new IncFCartesian<U>() {}; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fp.ilc; | |
import fp.kinds.__; | |
import fp.kinds.__2; | |
import fj.P2; | |
public interface IncF2<A,B> extends __2<IncF2.Mu,A,B> { | |
interface Mu {} | |
static <A,B> IncF2<A,B> narrow(__<__<IncF2.Mu,A>,B> a) { | |
return (IncF2<A,B>)a; | |
} | |
P2<Delta<B,?>,IncF2<A,B>> apply(Delta<A,?> delta); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment