hoist-error-0.1.0.1: Some convenience facilities for hoisting errors into a monad

Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Monad.Error.Hoist

Synopsis

Documentation

class Monad m => HoistError m t e e' | t -> e where Source

A tricky class for easily hoisting errors out of partiality types (e.g. Maybe, Either e) into a monad. The parameter e represents the error information carried by the partiality type t, and e' represents the type of error expected in the monad m.

Methods

hoistError :: (e -> e') -> t α -> m α Source

Given a conversion from the error in t α to e', we can hoist the computation into m.

Instances

MonadError e m => HoistError m Maybe () e 
MonadError e' m => HoistError m (Either e) e e' 

(<%?>) :: HoistError m t e e' => t α -> (e -> e') -> m α infixl 8 Source

A flipped synonym for hoistError.

(<%!?>) :: HoistError m t e e' => m (t α) -> (e -> e') -> m α infixl 8 Source

A version of <%?> that operates on values already in the monad.

(<?>) :: HoistError m t e e' => t α -> e' -> m α infixl 8 Source

A version of hoistError that ignores the error in t α and replaces it with a new one in e'.

(<!?>) :: HoistError m t e e' => m (t α) -> e' -> m α infixl 8 Source

A version of ? that operates on values already in the monad.