M
- the outer stack-safe monad
L
- the left typeR
- the right typepublic final class EitherT<M extends MonadRec<?,M>,L,R> extends Object implements Bifunctor<L,R,EitherT<M,?,?>>, MonadT<M,R,EitherT<M,L,?>,EitherT<?,L,?>>
monad transformer
for Either
.Modifier and Type | Method and Description |
---|---|
<L2,R2> EitherT<M,L2,R2> |
biMap(Fn1<? super L,? extends L2> lFn,
Fn1<? super R,? extends R2> rFn)
Dually map covariantly over both the left and right parameters.
|
<L2> EitherT<M,L2,R> |
biMapL(Fn1<? super L,? extends L2> fn)
Covariantly map over the left parameter.
|
<R2> EitherT<M,L,R2> |
biMapR(Fn1<? super R,? extends R2> fn)
Covariantly map over the right parameter.
|
<R2> EitherT<M,L,R2> |
discardL(Applicative<R2,EitherT<M,L,?>> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
<B> EitherT<M,L,R> |
discardR(Applicative<B,EitherT<M,L,?>> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
static <M extends MonadRec<?,M>,L,R> |
eitherT(MonadRec<Either<L,R>,M> melr)
|
boolean |
equals(Object other) |
<R2> EitherT<M,L,R2> |
flatMap(Fn1<? super R,? extends Monad<R2,EitherT<M,L,?>>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
<R2> EitherT<M,L,R2> |
fmap(Fn1<? super R,? extends R2> fn)
Covariantly transmute this functor's parameter using the given mapping function.
|
int |
hashCode() |
<R2> Lazy<EitherT<M,L,R2>> |
lazyZip(Lazy<? extends Applicative<Fn1<? super R,? extends R2>,EitherT<M,L,?>>> lazyAppFn)
Given a
lazy instance of this applicative over a mapping function, "zip" the two instances together
using whatever application semantics the current applicative supports. |
<R2,N extends MonadRec<?,N>> |
lift(MonadRec<R2,N> mb)
|
static <L> Lift<EitherT<?,L,?>> |
liftEitherT()
|
<R2> EitherT<M,L,R2> |
pure(R2 r2)
Lift the value
b into this applicative functor. |
static <M extends MonadRec<?,M>,L> |
pureEitherT(Pure<M> pureM)
|
<MELR extends MonadRec<Either<L,R>,M>> |
runEitherT()
Recover the full structure of the embedded
Monad . |
String |
toString() |
<R2> EitherT<M,L,R2> |
trampolineM(Fn1<? super R,? extends MonadRec<RecursiveResult<R,R2>,EitherT<M,L,?>>> fn)
Given some operation yielding a
RecursiveResult inside this MonadRec , internally trampoline the
operation until it yields a termination instruction. |
<R2> EitherT<M,L,R2> |
zip(Applicative<Fn1<? super R,? extends R2>,EitherT<M,L,?>> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using
whatever application semantics the current applicative supports.
|
public <MELR extends MonadRec<Either<L,R>,M>> MELR runEitherT()
Monad
.MELR
- the witnessed target typeMonad
public <R2,N extends MonadRec<?,N>> EitherT<N,L,R2> lift(MonadRec<R2,N> mb)
lift
in interface MonadBase<M extends MonadRec<?,M>,R,EitherT<?,L,?>>
lift
in interface MonadT<M extends MonadRec<?,M>,R,EitherT<M extends MonadRec<?,M>,L,?>,EitherT<?,L,?>>
R2
- the MonadRec
carrier typeN
- the argument MonadRec
witnessmb
- the argument MonadRec
MonadBase
public <R2> EitherT<M,L,R2> flatMap(Fn1<? super R,? extends Monad<R2,EitherT<M,L,?>>> f)
flatMap
in interface Monad<R,EitherT<M extends MonadRec<?,M>,L,?>>
flatMap
in interface MonadRec<R,EitherT<M extends MonadRec<?,M>,L,?>>
flatMap
in interface MonadT<M extends MonadRec<?,M>,R,EitherT<M extends MonadRec<?,M>,L,?>,EitherT<?,L,?>>
R2
- the resulting monad parameter typef
- the dependent computation over Apublic <R2> EitherT<M,L,R2> pure(R2 r2)
b
into this applicative functor.pure
in interface Applicative<R,EitherT<M extends MonadRec<?,M>,L,?>>
pure
in interface Monad<R,EitherT<M extends MonadRec<?,M>,L,?>>
pure
in interface MonadRec<R,EitherT<M extends MonadRec<?,M>,L,?>>
pure
in interface MonadT<M extends MonadRec<?,M>,R,EitherT<M extends MonadRec<?,M>,L,?>,EitherT<?,L,?>>
R2
- the type of the returned applicative's parameterr2
- the valuepublic <R2> EitherT<M,L,R2> fmap(Fn1<? super R,? extends R2> fn)
fmap
in interface Applicative<R,EitherT<M extends MonadRec<?,M>,L,?>>
fmap
in interface Functor<R,EitherT<M extends MonadRec<?,M>,L,?>>
fmap
in interface Monad<R,EitherT<M extends MonadRec<?,M>,L,?>>
fmap
in interface MonadRec<R,EitherT<M extends MonadRec<?,M>,L,?>>
fmap
in interface MonadT<M extends MonadRec<?,M>,R,EitherT<M extends MonadRec<?,M>,L,?>,EitherT<?,L,?>>
R2
- the new parameter typefn
- the mapping functionpublic <R2> EitherT<M,L,R2> zip(Applicative<Fn1<? super R,? extends R2>,EitherT<M,L,?>> appFn)
zip
in interface Applicative<R,EitherT<M extends MonadRec<?,M>,L,?>>
zip
in interface Monad<R,EitherT<M extends MonadRec<?,M>,L,?>>
zip
in interface MonadRec<R,EitherT<M extends MonadRec<?,M>,L,?>>
zip
in interface MonadT<M extends MonadRec<?,M>,R,EitherT<M extends MonadRec<?,M>,L,?>,EitherT<?,L,?>>
R2
- the resulting applicative parameter typeappFn
- the other applicative instancepublic <R2> Lazy<EitherT<M,L,R2>> lazyZip(Lazy<? extends Applicative<Fn1<? super R,? extends R2>,EitherT<M,L,?>>> lazyAppFn)
lazy
instance of this applicative over a mapping function, "zip" the two instances together
using whatever application semantics the current applicative supports. This is useful for applicatives that
support lazy evaluation and early termination.lazyZip
in interface Applicative<R,EitherT<M extends MonadRec<?,M>,L,?>>
lazyZip
in interface Monad<R,EitherT<M extends MonadRec<?,M>,L,?>>
lazyZip
in interface MonadRec<R,EitherT<M extends MonadRec<?,M>,L,?>>
lazyZip
in interface MonadT<M extends MonadRec<?,M>,R,EitherT<M extends MonadRec<?,M>,L,?>,EitherT<?,L,?>>
R2
- the resulting applicative parameter typelazyAppFn
- the lazy other applicative instanceMaybe
,
Either
public <R2> EitherT<M,L,R2> discardL(Applicative<R2,EitherT<M,L,?>> appB)
Applicative
and appB
, discarding this Applicative's
result and returning appB
. This is generally useful for sequentially performing side-effects.discardL
in interface Applicative<R,EitherT<M extends MonadRec<?,M>,L,?>>
discardL
in interface Monad<R,EitherT<M extends MonadRec<?,M>,L,?>>
discardL
in interface MonadRec<R,EitherT<M extends MonadRec<?,M>,L,?>>
discardL
in interface MonadT<M extends MonadRec<?,M>,R,EitherT<M extends MonadRec<?,M>,L,?>,EitherT<?,L,?>>
R2
- the type of the returned Applicative's parameterappB
- the other Applicativepublic <B> EitherT<M,L,R> discardR(Applicative<B,EitherT<M,L,?>> appB)
Applicative
and appB
, discarding appB's
result and
returning this Applicative
. This is generally useful for sequentially performing side-effects.discardR
in interface Applicative<R,EitherT<M extends MonadRec<?,M>,L,?>>
discardR
in interface Monad<R,EitherT<M extends MonadRec<?,M>,L,?>>
discardR
in interface MonadRec<R,EitherT<M extends MonadRec<?,M>,L,?>>
discardR
in interface MonadT<M extends MonadRec<?,M>,R,EitherT<M extends MonadRec<?,M>,L,?>,EitherT<?,L,?>>
B
- the type of appB's parameterappB
- the other Applicativepublic <R2> EitherT<M,L,R2> trampolineM(Fn1<? super R,? extends MonadRec<RecursiveResult<R,R2>,EitherT<M,L,?>>> fn)
RecursiveResult
inside this MonadRec
, internally trampoline the
operation until it yields a termination
instruction.
Stack-safety depends on implementations guaranteeing that the growth of the call stack is a constant factor independent of the number of invocations of the operation. For various examples of how this can be achieved in stereotypical circumstances, see the referenced types.
trampolineM
in interface MonadRec<R,EitherT<M extends MonadRec<?,M>,L,?>>
R2
- the ultimate resulting carrier typefn
- the function to internally trampolineMonadRec
for a basic implementation
,
for a {@link CoProduct2 coproduct} implementation
,
for an implementation leveraging an already stack-safe {@link Monad#flatMap(Fn1)}
,
for a {@link MonadT monad transformer} implementation
public <L2,R2> EitherT<M,L2,R2> biMap(Fn1<? super L,? extends L2> lFn, Fn1<? super R,? extends R2> rFn)
biMapL(lFn).biMapR(rFn)
.biMap
in interface Bifunctor<L,R,EitherT<M extends MonadRec<?,M>,?,?>>
biMap
in interface BoundedBifunctor<L,R,Object,Object,EitherT<M extends MonadRec<?,M>,?,?>>
L2
- the new left parameter typeR2
- the new right parameter typelFn
- the left parameter mapping functionrFn
- the right parameter mapping functionpublic <L2> EitherT<M,L2,R> biMapL(Fn1<? super L,? extends L2> fn)
biMapL
in interface Bifunctor<L,R,EitherT<M extends MonadRec<?,M>,?,?>>
biMapL
in interface BoundedBifunctor<L,R,Object,Object,EitherT<M extends MonadRec<?,M>,?,?>>
L2
- the new left parameter typefn
- the mapping functionpublic <R2> EitherT<M,L,R2> biMapR(Fn1<? super R,? extends R2> fn)
biMapR(f) == fmap(f)
.biMapR
in interface Bifunctor<L,R,EitherT<M extends MonadRec<?,M>,?,?>>
biMapR
in interface BoundedBifunctor<L,R,Object,Object,EitherT<M extends MonadRec<?,M>,?,?>>
R2
- the new right parameter typefn
- the mapping functionpublic static <M extends MonadRec<?,M>,L,R> EitherT<M,L,R> eitherT(MonadRec<Either<L,R>,M> melr)
public static <M extends MonadRec<?,M>,L> Pure<EitherT<M,L,?>> pureEitherT(Pure<M> pureM)