|
Control.Monad.Trans.Error | Portability | portable | Stability | experimental | Maintainer | ross@soi.city.ac.uk |
|
|
|
|
|
Description |
This monad transformer adds the ability to fail or throw exceptions
to a monad.
A sequence of actions succeeds, producing a value, only if all the
actions in the sequence are successful. If one fails with an error,
the rest of the sequence is skipped and the composite action fails
with that error.
If the value of the error is not required, the variant in
Control.Monad.Trans.Maybe may be used instead.
|
|
Synopsis |
|
|
|
|
The ErrorT monad transformer
|
|
|
An exception to be thrown.
Minimal complete definition: noMsg or strMsg.
| | Methods | | Creates an exception without a message.
The default implementation is strMsg "".
| | | Creates an exception with a message.
The default implementation of strMsg s is noMsg.
|
| | Instances | |
|
|
|
Workaround so that we can have a Haskell 98 instance Error String.
| | Methods | | | Instances | |
|
|
|
The error monad transformer. It can be used to add error handling
to other monads.
The ErrorT Monad structure is parameterized over two things:
- e - The error type.
- m - The inner monad.
The return function yields a successful computation, while >>=
sequences two subcomputations, failing on the first error.
| Constructors | | Instances | |
|
|
|
Map the unwrapped computation using the given function.
|
|
Error operations
|
|
|
Signal an error value e.
|
|
|
:: (Monad m, Error e) | | => ErrorT e m a | the inner computation
| -> e -> ErrorT e m a | a handler for errors in the inner
computation
| -> ErrorT e m a | | Handle an error.
|
|
|
Lifting other operations
|
|
|
Lift a callCC operation to the new monad.
|
|
|
Lift a listen operation to the new monad.
|
|
|
Lift a pass operation to the new monad.
|
|
Examples
|
|
Wrapping an IO action that can throw an error e:
type ErrorWithIO e a = ErrorT e IO a
==> ErrorT (IO (Either e a))
An IO monad wrapped in StateT inside of ErrorT:
type ErrorAndStateWithIO e s a = ErrorT e (StateT s IO) a
==> ErrorT (StateT s IO (Either e a))
==> ErrorT (StateT (s -> IO (Either e a,s)))
|
|
Produced by Haddock version 2.6.1 |