Class EitherT<M extends MonadRec<?,M>,L,R>
java.lang.Object
com.jnape.palatable.lambda.monad.transformer.builtin.EitherT<M,L,R>
- Type Parameters:
M- the outerstack-safe monadL- the left typeR- the right type
- All Implemented Interfaces:
Applicative<R,,EitherT<M, L, ?>> Bifunctor<L,,R, EitherT<M, ?, ?>> BoundedBifunctor<L,,R, Object, Object, EitherT<M, ?, ?>> Functor<R,,EitherT<M, L, ?>> Monad<R,,EitherT<M, L, ?>> MonadBase<M,,R, EitherT<?, L, ?>> MonadError<L,,R, EitherT<M, L, ?>> MonadRec<R,,EitherT<M, L, ?>> MonadT<M,R, EitherT<M, L, ?>, EitherT<?, L, ?>>
public 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,?>>, MonadError<L,R,EitherT<M,L,?>>
A
monad transformer for Either.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDually map covariantly over both the left and right parameters.Covariantly map over the left parameter.Covariantly map over the right parameter.discardL(Applicative<R2, EitherT<M, L, ?>> appB) Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB.discardR(Applicative<B, EitherT<M, L, ?>> appB) Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative.booleanChain dependent computations that may continue or short-circuit based on previous results.Covariantly transmute this functor's parameter using the given mapping function.inthashCode()Given alazyinstance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.pure(R2 r2) Lift the valuebinto this applicative functor.pureEitherT(Pure<M> pureM) Recover the full structure of the embeddedMonad.throwError(L l) Throw an error value of typeEinto themonad.toString()trampolineM(Fn1<? super R, ? extends MonadRec<RecursiveResult<R, R2>, EitherT<M, L, ?>>> fn) Given some operation yielding aRecursiveResultinside thisMonadRec, internally trampoline the operation until it yields aterminationinstruction.Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
-
Field Details
-
melr
-
-
Constructor Details
-
EitherT
-
-
Method Details
-
runEitherT
Recover the full structure of the embeddedMonad.- Type Parameters:
MELR- the witnessed target type- Returns:
- the embedded
Monad
-
lift
- Specified by:
liftin interfaceMonadBase<M extends MonadRec<?,M>, L, R> - Specified by:
liftin interfaceMonadT<M extends MonadRec<?,M>, R, EitherT<M extends MonadRec<?, M>, L, ?>, EitherT<?, L, ?>> - Type Parameters:
R2- theMonadReccarrier typeN- the argumentMonadRecwitness- Parameters:
mb- the argumentMonadRec- Returns:
- the new
MonadBase
-
flatMap
Chain dependent computations that may continue or short-circuit based on previous results.- Specified by:
flatMapin interfaceMonad<M extends MonadRec<?,M>, L> - Specified by:
flatMapin interfaceMonadError<M extends MonadRec<?,M>, L, R> - Specified by:
flatMapin interfaceMonadRec<M extends MonadRec<?,M>, L> - Specified by:
flatMapin interfaceMonadT<M extends MonadRec<?,M>, R, EitherT<M extends MonadRec<?, M>, L, ?>, EitherT<?, L, ?>> - Type Parameters:
R2- the resulting monad parameter type- Parameters:
f- the dependent computation over A- Returns:
- the new monad instance
-
pure
Lift the valuebinto this applicative functor.- Specified by:
purein interfaceApplicative<M extends MonadRec<?,M>, L> - Specified by:
purein interfaceMonad<M extends MonadRec<?,M>, L> - Specified by:
purein interfaceMonadError<M extends MonadRec<?,M>, L, R> - Specified by:
purein interfaceMonadRec<M extends MonadRec<?,M>, L> - Specified by:
purein interfaceMonadT<M extends MonadRec<?,M>, R, EitherT<M extends MonadRec<?, M>, L, ?>, EitherT<?, L, ?>> - Type Parameters:
R2- the type of the returned applicative's parameter- Parameters:
r2- the value- Returns:
- an instance of this applicative over b
-
fmap
Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.- Specified by:
fmapin interfaceApplicative<M extends MonadRec<?,M>, L> - Specified by:
fmapin interfaceFunctor<M extends MonadRec<?,M>, L> - Specified by:
fmapin interfaceMonad<M extends MonadRec<?,M>, L> - Specified by:
fmapin interfaceMonadError<M extends MonadRec<?,M>, L, R> - Specified by:
fmapin interfaceMonadRec<M extends MonadRec<?,M>, L> - Specified by:
fmapin interfaceMonadT<M extends MonadRec<?,M>, R, EitherT<M extends MonadRec<?, M>, L, ?>, EitherT<?, L, ?>> - Type Parameters:
R2- the new parameter type- Parameters:
fn- the mapping function- Returns:
- a functor over B (the new parameter type)
-
zip
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.- Specified by:
zipin interfaceApplicative<M extends MonadRec<?,M>, L> - Specified by:
zipin interfaceMonad<M extends MonadRec<?,M>, L> - Specified by:
zipin interfaceMonadError<M extends MonadRec<?,M>, L, R> - Specified by:
zipin interfaceMonadRec<M extends MonadRec<?,M>, L> - Specified by:
zipin interfaceMonadT<M extends MonadRec<?,M>, R, EitherT<M extends MonadRec<?, M>, L, ?>, EitherT<?, L, ?>> - Type Parameters:
R2- the resulting applicative parameter type- Parameters:
appFn- the other applicative instance- Returns:
- the mapped applicative
-
lazyZip
public <R2> Lazy<EitherT<M,L, lazyZipR2>> (Lazy<? extends Applicative<Fn1<? super R, ? extends R2>, EitherT<M, L, ?>>> lazyAppFn) Given alazyinstance 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.- Specified by:
lazyZipin interfaceApplicative<M extends MonadRec<?,M>, L> - Specified by:
lazyZipin interfaceMonad<M extends MonadRec<?,M>, L> - Specified by:
lazyZipin interfaceMonadError<M extends MonadRec<?,M>, L, R> - Specified by:
lazyZipin interfaceMonadRec<M extends MonadRec<?,M>, L> - Specified by:
lazyZipin interfaceMonadT<M extends MonadRec<?,M>, R, EitherT<M extends MonadRec<?, M>, L, ?>, EitherT<?, L, ?>> - Type Parameters:
R2- the resulting applicative parameter type- Parameters:
lazyAppFn- the lazy other applicative instance- Returns:
- the mapped applicative
- See Also:
-
discardL
Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB. This is generally useful for sequentially performing side-effects.- Specified by:
discardLin interfaceApplicative<M extends MonadRec<?,M>, L> - Specified by:
discardLin interfaceMonad<M extends MonadRec<?,M>, L> - Specified by:
discardLin interfaceMonadError<M extends MonadRec<?,M>, L, R> - Specified by:
discardLin interfaceMonadRec<M extends MonadRec<?,M>, L> - Specified by:
discardLin interfaceMonadT<M extends MonadRec<?,M>, R, EitherT<M extends MonadRec<?, M>, L, ?>, EitherT<?, L, ?>> - Type Parameters:
R2- the type of the returned Applicative's parameter- Parameters:
appB- the other Applicative- Returns:
- appB
-
discardR
Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative. This is generally useful for sequentially performing side-effects.- Specified by:
discardRin interfaceApplicative<M extends MonadRec<?,M>, L> - Specified by:
discardRin interfaceMonad<M extends MonadRec<?,M>, L> - Specified by:
discardRin interfaceMonadError<M extends MonadRec<?,M>, L, R> - Specified by:
discardRin interfaceMonadRec<M extends MonadRec<?,M>, L> - Specified by:
discardRin interfaceMonadT<M extends MonadRec<?,M>, R, EitherT<M extends MonadRec<?, M>, L, ?>, EitherT<?, L, ?>> - Type Parameters:
B- the type of appB's parameter- Parameters:
appB- the other Applicative- Returns:
- this Applicative
-
throwError
Throw an error value of typeEinto themonad.- Specified by:
throwErrorin interfaceMonadError<M extends MonadRec<?,M>, L, R> - Parameters:
l- the error type- Returns:
- the
monad
-
catchError
- Specified by:
catchErrorin interfaceMonadError<M extends MonadRec<?,M>, L, R> - Parameters:
recoveryFn- the catch function- Returns:
- the recovered
Monad
-
trampolineM
public <R2> EitherT<M,L, trampolineMR2> (Fn1<? super R, ? extends MonadRec<RecursiveResult<R, R2>, EitherT<M, L, ?>>> fn) Given some operation yielding aRecursiveResultinside thisMonadRec, internally trampoline the operation until it yields aterminationinstruction.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.
-
biMap
public <L2,R2> EitherT<M,L2, biMapR2> (Fn1<? super L, ? extends L2> lFn, Fn1<? super R, ? extends R2> rFn) Dually map covariantly over both the left and right parameters. This is isomorphic tobiMapL(lFn).biMapR(rFn).- Specified by:
biMapin interfaceBifunctor<M extends MonadRec<?,M>, L, R> - Specified by:
biMapin interfaceBoundedBifunctor<L,R, Object, Object, EitherT<M extends MonadRec<?, M>, ?, ?>> - Type Parameters:
L2- the new left parameter typeR2- the new right parameter type- Parameters:
lFn- the left parameter mapping functionrFn- the right parameter mapping function- Returns:
- a bifunctor over C (the new left parameter type) and D (the new right parameter type)
-
biMapL
Covariantly map over the left parameter.- Specified by:
biMapLin interfaceBifunctor<M extends MonadRec<?,M>, L, R> - Specified by:
biMapLin interfaceBoundedBifunctor<L,R, Object, Object, EitherT<M extends MonadRec<?, M>, ?, ?>> - Type Parameters:
L2- the new left parameter type- Parameters:
fn- the mapping function- Returns:
- a bifunctor over C (the new left parameter) and B (the same right parameter)
-
biMapR
Covariantly map over the right parameter. For all bifunctors that are also functors, it should hold thatbiMapR(f) == fmap(f).- Specified by:
biMapRin interfaceBifunctor<M extends MonadRec<?,M>, L, R> - Specified by:
biMapRin interfaceBoundedBifunctor<L,R, Object, Object, EitherT<M extends MonadRec<?, M>, ?, ?>> - Type Parameters:
R2- the new right parameter type- Parameters:
fn- the mapping function- Returns:
- a bifunctor over A (the same left parameter) and C (the new right parameter)
-
equals
-
hashCode
public int hashCode() -
toString
-
eitherT
-
pureEitherT
-
liftEitherT
-