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`

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`.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7131345,"math_prob":0.8722274,"size":1836,"snap":"2022-05-2022-21","text_gpt3_token_len":554,"char_repetition_ratio":0.20087336,"word_repetition_ratio":0.3259053,"special_character_ratio":0.3017429,"punctuation_ratio":0.10693642,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9826498,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-25T07:45:02Z\",\"WARC-Record-ID\":\"<urn:uuid:7f84b5c2-54a6-4539-baeb-fc8af9077375>\",\"Content-Length\":\"21162\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5effaf92-b83b-43f4-8c87-fa756fc1a1a1>\",\"WARC-Concurrent-To\":\"<urn:uuid:e85c29ef-c0c5-4584-84a9-e06c070bc1d7>\",\"WARC-IP-Address\":\"147.75.55.189\",\"WARC-Target-URI\":\"https://hackage-origin.haskell.org/package/either-4.3.3.2/docs/Control-Monad-Trans-Either.html\",\"WARC-Payload-Digest\":\"sha1:MM452FXBNGUXZL2HDY7RIS6Y2C23DK5Z\",\"WARC-Block-Digest\":\"sha1:MWHUJEIA6MCJZKZUXOBP57FZ7F3BXMXQ\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662580803.75_warc_CC-MAIN-20220525054507-20220525084507-00555.warc.gz\"}"}