|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjedi.either.Either<A,B>
public abstract class Either<A,B>
The Either type represents a value of one of two possible types
(a disjoint union) and was Inspired by Scala's Either.
| Constructor Summary | |
|---|---|
Either()
|
|
| Method Summary | ||
|---|---|---|
abstract List<A> |
asList()
|
|
static
|
cond(boolean cond,
A a,
B b)
If the condition satisfies, return the given A in Left,
otherwise, return the given B in Right. |
|
static
|
cond(boolean cond,
Functor0<A> a,
Functor0<B> b)
If the condition satisfies, return the result of executing a in Left,
otherwise, return the result of executing b in Right. |
|
abstract void |
execute(Command<A> ca,
Command<B> cb)
|
|
abstract
|
flatMap(Functor<? super A,Either<X,B>> f)
|
|
abstract
|
fold(Functor<? super A,X> fa,
Functor<? super B,X> fb)
Deconstruction of the type. |
|
boolean |
isLeft()
|
|
boolean |
isRight()
|
|
LeftProjection<A,B> |
left()
|
|
abstract
|
map(Functor<? super A,X> f)
Maps the function argument through Left. |
|
RightProjection<A,B> |
right()
|
|
abstract Either<B,A> |
swap()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Either()
| Method Detail |
|---|
public static <A,B> Either<A,B> cond(boolean cond,
A a,
B b)
Left,
otherwise, return the given B in Right.
public static <A,B> Either<A,B> cond(boolean cond,
Functor0<A> a,
Functor0<B> b)
Left,
otherwise, return the result of executing b in Right.
public boolean isLeft()
public boolean isRight()
public LeftProjection<A,B> left()
public RightProjection<A,B> right()
public abstract <X> X fold(Functor<? super A,X> fa,
Functor<? super B,X> fb)
fa - the functor to apply if this is a Leftfb - the functor to apply if this is a Left
public abstract void execute(Command<A> ca,
Command<B> cb)
public abstract Either<B,A> swap()
public abstract List<A> asList()
public abstract <X> Either<X,B> map(Functor<? super A,X> f)
Left.
public abstract <X> Either<X,B> flatMap(Functor<? super A,Either<X,B>> f)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||