Description

This module provides a minimalist Either monad transformer.

Synopsis

Documentation

newtype EitherT e m a Source #

EitherT is a version of ErrorT that does not require a spurious Error instance for the Left case.

Either is a perfectly usable Monad without such a constraint. ErrorT is not the generalization of the current Either monad, it is something else.

This is necessary for both theoretical and practical reasons. For instance an apomorphism is the generalized anamorphism for this Monad, but it cannot be written with ErrorT.

In addition to the combinators here, the errors package provides a large number of combinators for working with this type.

Constructors

 EitherT FieldsrunEitherT :: m (Either e a)

Instances

eitherT :: Monad m => (a -> m c) -> (b -> m c) -> EitherT a m b -> m c Source #

Given a pair of actions, one to perform in case of failure, and one to perform in case of success, run an EitherT and get back a monadic result.

bimapEitherT :: Functor m => (e -> f) -> (a -> b) -> EitherT e m a -> EitherT f m b Source #

Map over both failure and success.

mapEitherT :: (m (Either e a) -> n (Either e' b)) -> EitherT e m a -> EitherT e' n b Source #

Map the unwrapped computation using the given function.

runEitherT (mapEitherT f m) = f (runEitherT m)


hoistEither :: Monad m => Either e a -> EitherT e m a Source #

Lift an Either into an EitherT

bracketEitherT :: Monad m => EitherT e m a -> (a -> EitherT e m b) -> (a -> EitherT e m c) -> EitherT e m c Source #

Acquire a resource in EitherT and then perform an action with it, cleaning up afterwards regardless of error. Like bracket, but acting only in EitherT.

bracketEitherT_ :: Monad m => EitherT e m a -> EitherT e m b -> EitherT e m c -> EitherT e m c Source #

Version of bracketEitherT which discards the result from the initial action.

left :: Monad m => e -> EitherT e m a Source #

Analogous to Left. Equivalent to throwError.

right :: Monad m => a -> EitherT e m a Source #

Analogous to Right. Equivalent to return.

swapEitherT :: Functor m => EitherT e m a -> EitherT a m e Source #

Monad transformer version of swapEither.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.4749700129032135, "perplexity": 4571.821730286215}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2017-30/segments/1500549423486.26/warc/CC-MAIN-20170720201925-20170720221925-00310.warc.gz"}