monad-abort-fd-0.7: A better error monad transformer

Safe HaskellNone
LanguageHaskell98

Control.Monad.Abort.Class

Contents

Description

Monad type classes for raising errors and recovering from them.

Synopsis

Documentation

class (Applicative μ, Monad μ) => MonadAbort e μ | μ -> e where Source #

Class of monads that support raising of errors.

Minimal complete definition

abort

Methods

abort :: e -> μ α Source #

Raise an error.

    abort e >>= rest = abort e

Instances

MonadAbort SomeException IO Source # 

Methods

abort :: SomeException -> IO α Source #

MonadAbort SomeException STM Source # 

Methods

abort :: SomeException -> STM α Source #

MonadAbort e μ => MonadAbort e (ListT μ) Source # 

Methods

abort :: e -> ListT μ α Source #

MonadAbort e μ => MonadAbort e (MaybeT μ) Source # 

Methods

abort :: e -> MaybeT μ α Source #

MonadAbort e μ => MonadAbort e (FinishT f μ) Source # 

Methods

abort :: e -> FinishT f μ α Source #

MonadAbort e μ => MonadAbort e (SelectT r μ) Source # 

Methods

abort :: e -> SelectT r μ α Source #

(Monoid w, MonadAbort e μ) => MonadAbort e (AccumT w μ) Source # 

Methods

abort :: e -> AccumT w μ α Source #

(Functor μ, Monad μ) => MonadAbort e (ExceptT e μ) Source # 

Methods

abort :: e -> ExceptT e μ α Source #

(Functor μ, Monad μ, Error e) => MonadAbort e (ErrorT e μ) Source # 

Methods

abort :: e -> ErrorT e μ α Source #

(MonadAbort e μ, Monoid w) => MonadAbort e (WriterT w μ) Source # 

Methods

abort :: e -> WriterT w μ α Source #

(MonadAbort e μ, Monoid w) => MonadAbort e (WriterT w μ) Source # 

Methods

abort :: e -> WriterT w μ α Source #

MonadAbort e μ => MonadAbort e (StateT s μ) Source # 

Methods

abort :: e -> StateT s μ α Source #

MonadAbort e μ => MonadAbort e (StateT s μ) Source # 

Methods

abort :: e -> StateT s μ α Source #

MonadAbort e μ => MonadAbort e (IdentityT * μ) Source # 

Methods

abort :: e -> IdentityT * μ α Source #

(Functor μ, Monad μ) => MonadAbort e (AbortT e μ) Source # 

Methods

abort :: e -> AbortT e μ α Source #

MonadAbort e μ => MonadAbort e (ReaderT * r μ) Source # 

Methods

abort :: e -> ReaderT * r μ α Source #

MonadAbort e μ => MonadAbort e (ContT * r μ) Source # 

Methods

abort :: e -> ContT * r μ α Source #

(MonadAbort e μ, Monoid w) => MonadAbort e (RWST r w s μ) Source # 

Methods

abort :: e -> RWST r w s μ α Source #

(MonadAbort e μ, Monoid w) => MonadAbort e (RWST r w s μ) Source # 

Methods

abort :: e -> RWST r w s μ α Source #

class MonadAbort e μ => MonadRecover e μ | μ -> e where Source #

Class of monads that support recovery from errors.

Minimal complete definition

recover | evaluate

Methods

recover :: μ α -> (e -> μ α) -> μ α Source #

recover m h recovers from errors raised in computation m using the provided error handler h. The default implementation is

  evaluate m >>= either h return

evaluate :: μ α -> μ (Either e α) Source #

evaluate m runs computation m, returning Left e if it raised an error e. The default implementation is

   recover (Right <$> m) (return . Left)

Instances

MonadRecover SomeException IO Source # 

Methods

recover :: IO α -> (SomeException -> IO α) -> IO α Source #

evaluate :: IO α -> IO (Either SomeException α) Source #

MonadRecover SomeException STM Source # 

Methods

recover :: STM α -> (SomeException -> STM α) -> STM α Source #

evaluate :: STM α -> STM (Either SomeException α) Source #

MonadRecover e μ => MonadRecover e (ListT μ) Source # 

Methods

recover :: ListT μ α -> (e -> ListT μ α) -> ListT μ α Source #

evaluate :: ListT μ α -> ListT μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (MaybeT μ) Source # 

Methods

recover :: MaybeT μ α -> (e -> MaybeT μ α) -> MaybeT μ α Source #

evaluate :: MaybeT μ α -> MaybeT μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (FinishT f μ) Source # 

Methods

recover :: FinishT f μ α -> (e -> FinishT f μ α) -> FinishT f μ α Source #

evaluate :: FinishT f μ α -> FinishT f μ (Either e α) Source #

(Monoid w, MonadRecover e μ) => MonadRecover e (AccumT w μ) Source # 

Methods

recover :: AccumT w μ α -> (e -> AccumT w μ α) -> AccumT w μ α Source #

evaluate :: AccumT w μ α -> AccumT w μ (Either e α) Source #

(Functor μ, Monad μ) => MonadRecover e (ExceptT e μ) Source # 

Methods

recover :: ExceptT e μ α -> (e -> ExceptT e μ α) -> ExceptT e μ α Source #

evaluate :: ExceptT e μ α -> ExceptT e μ (Either e α) Source #

(Functor μ, Monad μ, Error e) => MonadRecover e (ErrorT e μ) Source # 

Methods

recover :: ErrorT e μ α -> (e -> ErrorT e μ α) -> ErrorT e μ α Source #

evaluate :: ErrorT e μ α -> ErrorT e μ (Either e α) Source #

(MonadRecover e μ, Monoid w) => MonadRecover e (WriterT w μ) Source # 

Methods

recover :: WriterT w μ α -> (e -> WriterT w μ α) -> WriterT w μ α Source #

evaluate :: WriterT w μ α -> WriterT w μ (Either e α) Source #

(MonadRecover e μ, Monoid w) => MonadRecover e (WriterT w μ) Source # 

Methods

recover :: WriterT w μ α -> (e -> WriterT w μ α) -> WriterT w μ α Source #

evaluate :: WriterT w μ α -> WriterT w μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (StateT s μ) Source # 

Methods

recover :: StateT s μ α -> (e -> StateT s μ α) -> StateT s μ α Source #

evaluate :: StateT s μ α -> StateT s μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (StateT s μ) Source # 

Methods

recover :: StateT s μ α -> (e -> StateT s μ α) -> StateT s μ α Source #

evaluate :: StateT s μ α -> StateT s μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (IdentityT * μ) Source # 

Methods

recover :: IdentityT * μ α -> (e -> IdentityT * μ α) -> IdentityT * μ α Source #

evaluate :: IdentityT * μ α -> IdentityT * μ (Either e α) Source #

(Functor μ, Monad μ) => MonadRecover e (AbortT e μ) Source # 

Methods

recover :: AbortT e μ α -> (e -> AbortT e μ α) -> AbortT e μ α Source #

evaluate :: AbortT e μ α -> AbortT e μ (Either e α) Source #

MonadRecover e μ => MonadRecover e (ReaderT * r μ) Source # 

Methods

recover :: ReaderT * r μ α -> (e -> ReaderT * r μ α) -> ReaderT * r μ α Source #

evaluate :: ReaderT * r μ α -> ReaderT * r μ (Either e α) Source #

(MonadRecover e μ, Monoid w) => MonadRecover e (RWST r w s μ) Source # 

Methods

recover :: RWST r w s μ α -> (e -> RWST r w s μ α) -> RWST r w s μ α Source #

evaluate :: RWST r w s μ α -> RWST r w s μ (Either e α) Source #

(MonadRecover e μ, Monoid w) => MonadRecover e (RWST r w s μ) Source # 

Methods

recover :: RWST r w s μ α -> (e -> RWST r w s μ α) -> RWST r w s μ α Source #

evaluate :: RWST r w s μ α -> RWST r w s μ (Either e α) Source #

onError :: MonadRecover e μ => μ α -> (e -> μ β) -> μ α Source #

Run an action on error, without recovering from it.

onError_ :: MonadRecover e μ => μ α -> μ β -> μ α Source #

Run an action on error (ignoring the error value), without recovering from it.

ignoreErrors :: MonadRecover e μ => μ α -> μ () Source #

Silently recover from all errors.

Orphan instances

MonadRWS r w s μ => MonadRWS r w s (AbortT e μ) Source # 
MonadReader r μ => MonadReader r (AbortT e μ) Source # 

Methods

ask :: AbortT e μ r #

local :: (r -> r) -> AbortT e μ a -> AbortT e μ a #

reader :: (r -> a) -> AbortT e μ a #

MonadState s μ => MonadState s (AbortT e μ) Source # 

Methods

get :: AbortT e μ s #

put :: s -> AbortT e μ () #

state :: (s -> (a, s)) -> AbortT e μ a #

MonadWriter w μ => MonadWriter w (AbortT e μ) Source # 

Methods

writer :: (a, w) -> AbortT e μ a #

tell :: w -> AbortT e μ () #

listen :: AbortT e μ a -> AbortT e μ (a, w) #

pass :: AbortT e μ (a, w -> w) -> AbortT e μ a #

Monad μ => MonadError e (AbortT e μ) Source # 

Methods

throwError :: e -> AbortT e μ a #

catchError :: AbortT e μ a -> (e -> AbortT e μ a) -> AbortT e μ a #

MonadCont μ => MonadCont (AbortT e μ) Source # 

Methods

callCC :: ((a -> AbortT e μ b) -> AbortT e μ a) -> AbortT e μ a #