The strategy of combining computations that can throw exceptions by bypassing bound functions from the point an exception is thrown to the point that it is handled.
Is parameterized over the type of error information and
the monad type constructor.
It is common to use as the monad type constructor
for an error monad in which error descriptions take the form of strings.
In that case and many other common cases the resulting monad is already defined
as an instance of the MonadError class.
You can also define your own a monad type constructor
other than Data.Either String, in which case you will have to explicitly define
an instance of the MonadError class.Data.Either e
Methods
throwError :: ErrorType m -> m aIs used within a monadic computation to begin exception processing.
catchError :: m a -> (ErrorType m -> m a) -> m aA handler function to handle previous errors and return to normal execution. A common idiom is:
do { action1; action2; action3 } `catchError` handlerwhere the
actionfunctions can call throwError. Note thathandlerand the do-block must have the same return type.
Instances12MonadError, …
MonadError IODefined in monads-tf-0.3.0.1 · Control.Monad.Except.ClassMonadError (Either e)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.ClassMonadError m => MonadError (MaybeT m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.ClassMonad m => MonadError (ExceptT e m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.ClassMonadError m => MonadError (IdentityT m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.ClassMonadError m => MonadError (ReaderT r m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.ClassMonadError m => MonadError (StateT s m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.ClassMonadError m => MonadError (StateT s m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.Class(Monoid w, MonadError m) => MonadError (WriterT w m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.Class(Monoid w, MonadError m) => MonadError (WriterT w m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.Class(Monoid w, MonadError m) => MonadError (RWST r w s m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.Class(Monoid w, MonadError m) => MonadError (RWST r w s m)Defined in monads-tf-0.3.0.1 · Control.Monad.Except.Class