Last active
July 30, 2017 18:26
-
-
Save nachivpn/e6bae0f2d2386e2382f393d6a3d5f572 to your computer and use it in GitHub Desktop.
EitherPartial.java
This file contains hidden or 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
public abstract class Either<L, R>{ | |
//used for pattern matching on contained value and processing/transforming it using some function | |
public abstract <T> T match(Function<L, T> a, Function<R, T> b); | |
//used to apply/compose functions which accapet a R (right) value and return an Either | |
//very useful to chain "either computations" | |
public abstract <S> Either<L, S> bind(Function<R, Either<L, S>> f); | |
//used to apply a simple generic R to S function on the R value contained inside an Either | |
//enables re-use of non-Either functions in the Either context | |
public abstract <S> Either<L,S> fmap(Function<R, S> f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment