```{-|
Use this module to convert between 'Maybe', 'Either', 'MaybeT', and
'EitherT'.
-}

module Control.Error.Util where

-- | Suppress the 'Left' value of an 'Either'
hush :: Either a b -> Maybe b
hush e = case e of
Left  _ -> Nothing
Right b -> Just b

-- | Suppress the 'Left' value of an 'EitherT'
hushT :: (Monad m) => EitherT a m b -> MaybeT m b
hushT = MaybeT . liftM hush . runEitherT

-- | Tag the 'Nothing' value of a 'Maybe'
note :: a -> Maybe b -> Either a b
note a m = case m of
Nothing -> Left  a
Just b  -> Right b

-- | Tag the 'Nothing' value of a 'MaybeT'
noteT :: (Monad m) => a -> MaybeT m b -> EitherT a m b
noteT a = EitherT . liftM (note a) . runMaybeT

-- | Lift a 'Maybe' to the 'MaybeT' monad
liftMaybe :: (Monad m) => Maybe b -> MaybeT m b
liftMaybe = MaybeT . return

-- | Lift an 'Either' to the 'EitherT' monad
liftEither :: (Monad m) => Either a b -> EitherT a m b
liftEither = EitherT . return
```
{"ft_lang_label":"__label__en","ft_lang_prob":0.5803615,"math_prob":0.80254805,"size":650,"snap":"2019-26-2019-30","text_gpt3_token_len":206,"char_repetition_ratio":0.19814241,"word_repetition_ratio":0.04477612,"special_character_ratio":0.3276923,"punctuation_ratio":0.19285715,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9794594,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-06-17T14:06:03Z\",\"WARC-Record-ID\":\"<urn:uuid:e4a7a635-364c-41d0-808d-d9b28cdf380c>\",\"Content-Length\":\"8392\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:475fbc3a-704a-4355-ac68-bfac259e3a7a>\",\"WARC-Concurrent-To\":\"<urn:uuid:70123187-40ab-40fa-8378-9863b1469bf8>\",\"WARC-IP-Address\":\"151.101.248.68\",\"WARC-Target-URI\":\"http://hackage.haskell.org/package/errors-1.0.0/docs/src/Control-Error-Util.html\",\"WARC-Payload-Digest\":\"sha1:SKDKUEDMOY6EPX3ZMBETCG63MH7MJG7O\",\"WARC-Block-Digest\":\"sha1:HD3L6VWB3QNAF2DZANQC7TNWP4VWK6MN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-26/CC-MAIN-2019-26_segments_1560627998475.92_warc_CC-MAIN-20190617123027-20190617145027-00272.warc.gz\"}"}