E
- the error typeM
- the Monad
witnessA
- the carrierpublic interface MonadError<E,A,M extends MonadError<E,?,M>> extends Monad<A,M>
monads
that can be interrupted with some type of error. The type of error is fully
dictated by the instance of MonadError
and is not necessarily analogous to Java exceptions
or even Throwable
. For instance, IO
can be thrown any Throwable
, where as Either
can
only be "thrown" a value of its left
type.Modifier and Type | Method and Description |
---|---|
MonadError<E,A,M> |
catchError(Fn1<? super E,? extends Monad<A,M>> recoveryFn)
|
default <B> MonadError<E,B,M> |
discardL(Applicative<B,M> appB)
Sequence both this
Applicative and appB , discarding this Applicative's
result and returning appB . |
default <B> MonadError<E,A,M> |
discardR(Applicative<B,M> appB)
Sequence both this
Applicative and appB , discarding appB's result and
returning this Applicative . |
<B> MonadError<E,B,M> |
flatMap(Fn1<? super A,? extends Monad<B,M>> f)
Chain dependent computations that may continue or short-circuit based on previous results.
|
default <B> MonadError<E,B,M> |
fmap(Fn1<? super A,? extends B> fn)
Covariantly transmute this functor's parameter using the given mapping function.
|
default <B> Lazy<? extends MonadError<E,B,M>> |
lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,M>> 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. |
<B> MonadError<E,B,M> |
pure(B b)
Lift the value
b into this applicative functor. |
MonadError<E,A,M> |
throwError(E e)
Throw an error value of type
E into the monad . |
default <B> MonadError<E,B,M> |
zip(Applicative<Fn1<? super A,? extends B>,M> appFn)
Given another instance of this applicative over a mapping function, "zip" the two instances together using
whatever application semantics the current applicative supports.
|
MonadError<E,A,M> throwError(E e)
E
into the monad
.e
- the error typemonad
MonadError<E,A,M> catchError(Fn1<? super E,? extends Monad<A,M>> recoveryFn)
recoveryFn
- the catch functionMonad
<B> MonadError<E,B,M> flatMap(Fn1<? super A,? extends Monad<B,M>> f)
<B> MonadError<E,B,M> pure(B b)
b
into this applicative functor.pure
in interface Applicative<A,M extends MonadError<E,?,M>>
pure
in interface Monad<A,M extends MonadError<E,?,M>>
B
- the type of the returned applicative's parameterb
- the valuedefault <B> MonadError<E,B,M> fmap(Fn1<? super A,? extends B> fn)
fmap
in interface Applicative<A,M extends MonadError<E,?,M>>
fmap
in interface Functor<A,M extends MonadError<E,?,M>>
fmap
in interface Monad<A,M extends MonadError<E,?,M>>
B
- the new parameter typefn
- the mapping functiondefault <B> MonadError<E,B,M> zip(Applicative<Fn1<? super A,? extends B>,M> appFn)
zip
in interface Applicative<A,M extends MonadError<E,?,M>>
zip
in interface Monad<A,M extends MonadError<E,?,M>>
B
- the resulting applicative parameter typeappFn
- the other applicative instancedefault <B> Lazy<? extends MonadError<E,B,M>> lazyZip(Lazy<? extends Applicative<Fn1<? super A,? extends B>,M>> 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<A,M extends MonadError<E,?,M>>
lazyZip
in interface Monad<A,M extends MonadError<E,?,M>>
B
- the resulting applicative parameter typelazyAppFn
- the lazy other applicative instanceMaybe
,
Either
default <B> MonadError<E,B,M> discardL(Applicative<B,M> 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<A,M extends MonadError<E,?,M>>
discardL
in interface Monad<A,M extends MonadError<E,?,M>>
B
- the type of the returned Applicative's parameterappB
- the other Applicativedefault <B> MonadError<E,A,M> discardR(Applicative<B,M> 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<A,M extends MonadError<E,?,M>>
discardR
in interface Monad<A,M extends MonadError<E,?,M>>
B
- the type of appB's parameterappB
- the other Applicative