Interface MonadError<E, A, M extends MonadError<E,?,M>>
- Type Parameters:
E- the error typeA- the carrierM- theMonadwitness
- All Superinterfaces:
Applicative<A,M>, Functor<A, M>, Monad<A, M>
- All Known Implementing Classes:
Either, Either.Left, Either.Right, EitherT, IO, IO.Compose, Maybe, Maybe.Just, Maybe.Nothing, MaybeT, Try, Try.Failure, Try.Success
An interface for
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.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionMonadError<E, A, M> default <B> MonadError<E, B, M> discardL(Applicative<B, M> appB) Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB.default <B> MonadError<E, A, M> discardR(Applicative<B, M> appB) Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative.<B> MonadError<E, B, M> Chain dependent computations that may continue or short-circuit based on previous results.default <B> MonadError<E, B, M> Covariantly transmute this functor's parameter using the given mapping function.default <B> Lazy<? extends MonadError<E, B, M>> Given alazyinstance 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 valuebinto this applicative functor.MonadError<E, A, M> throwError(E e) Throw an error value of typeEinto themonad.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.
-
Method Details
-
throwError
-
catchError
-
flatMap
Chain dependent computations that may continue or short-circuit based on previous results. -
pure
Lift the valuebinto this applicative functor. -
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. -
zip
Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. -
lazyZip
default <B> Lazy<? extends MonadError<E,B, lazyZipM>> (Lazy<? extends Applicative<Fn1<? super A, ? extends B>, M>> 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. -
discardL
Sequence both thisApplicativeandappB, discarding thisApplicative'sresult and returningappB. This is generally useful for sequentially performing side-effects. -
discardR
Sequence both thisApplicativeandappB, discardingappB'sresult and returning thisApplicative. This is generally useful for sequentially performing side-effects.
-