| Copyright | (c) Michael Weber <[email protected]> 2001 (c) Jeff Newbern 2003-2006 (c) Andriy Palamarchuk 2006 (c) Edward Kmett 2012 |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | [email protected] |
| Stability | experimental |
| Portability | non-portable (multi-parameter type classes) |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Control.Monad.Error.Class
Description
EitherString aThe Error monad (also called the Exception monad).
Minimal complete definition
Nothing
Methods
Creates an exception without a message. The default implementation is.strMsg ""
| ErrorIOException | |
Instance detailsDefined inControl.Monad.Trans.Error | |
| ErrorList a =>Error [a] | A string can be thrown as an error. |
classMonad m =>MonadError e m | m -> ewhereSource#
The strategy of combining computations that can throw exceptionsby bypassing bound functionsfrom the point an exception is thrown to the point that it is handled.
Is parameterized over the type of error information andthe monad type constructor.It is common to use as the monad type constructorfor 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 definedas an instance of theEither StringMonadError class.You can also define your own error type and/or use a monad type constructorother than orEitherString.In these cases you will have to explicitly define instances of theEitherIOErrorMonadErrorclass.(If you are using the deprecatedControl.Monad.Error orControl.Monad.Trans.Error, you may also have to define anError instance.)
Methods
throwError :: e -> m aSource#
Is used within a monadic computation to begin exception processing.
catchError :: m a -> (e -> m a) -> m aSource#
A handler function to handle previous errors and return to normal execution. A common idiom is:
do { action1; action2; action3 } `catchError` handlerwhere theaction functions can callthrowError. Note thathandler and the do-block must have the same return type.
liftEither ::MonadError e m =>Either e a -> m aSource#
Lifts an into anyEither e.MonadError e
do { val <- liftEither =<< action1; action2 }whereaction1 returns anEither to represent errors.
Since: mtl-2.2.2
Produced byHaddock version 2.23.0