|
Control.Monad.Exception.Synchronous |
|
|
Description |
Synchronous exceptions immediately abort a series of computations.
We provide monads for describing this behaviour.
In contrast to ErrorT from mtl or transformers package
we do not pose restrictions on the exception type.
How to tell, that a function can possibly throw more than one (kind of) exception?
If you would use the exception type (Either ParserException IOError)
then this is different from (Either IOError ParserException).
Thus we recommned using type classes for exceptions.
Then you can use one type containing all exceptions in an application,
but the type signature still tells which exceptions are actually possible.
Examples:
parser :: ParserException e => ExceptionalT e ParserMonad a
getLine :: IOException e => ExceptionalT e IO String
fileParser :: (ParserException e, IOException e) => ExceptionalT e IO String
Unfortunately, this way you cannot remove single exceptions
from the constraints by catching them.
You can only remove all of them using resolve or none.
For a more advanced approach,
that allows removing exceptions constraints
by some non-Haskell-98 type hackery,
see the exception package by Joseph Iborra.
|
|
Synopsis |
|
|
|
Documentation |
|
|
Like Either, but explicitly intended for handling of exceptional results.
In contrast to Either we do not support fail.
Calling fail in the Exceptional monad is an error.
This way, we do not require that an exception can be derived from a String,
yet, we require no constraint on the exception type at all.
| Constructors | |
|
|
|
|
|
|
|
|
|
|
|
useful in connection with Control.Monad.Exception.Asynchronous.continue
|
|
|
Counterpart to either for Either.
|
|
|
If you are sure that the value is always a Success
you can tell that the run-time system
thus making your program lazy.
However, try to avoid this function by using catch and friends,
since this function is partial.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
newtype ExceptionalT e m a | Source |
|
like ErrorT, but ExceptionalT is the better name in order to distinguish from real (programming) errors
| Constructors | |
|
|
|
|
|
|
|
|
|
|
|
see force
|
|
|
|
|
|
|
|
|
|
|
|
|
If the enclosed monad has custom exception facilities,
they could skip the cleanup code.
Make sure, that this cannot happen by choosing an appropriate monad.
|
|
|
|
|
|
|
:: Monad m | | => e0 -> Maybe e1 | cons function
| -> a -> b -> b | empty | -> b | atomic action to repeat
| -> ExceptionalT e0 m a | | -> ExceptionalT e1 m b | | Repeat an action until an exception occurs.
Initialize the result with empty and add new elements using cons
(e.g. [] and (:)).
The exception handler decides whether the terminating exception
is re-raised (Just) or catched (Nothing).
|
|
|
|
|
|
Produced by Haddock version 2.6.0 |