|
|
|
|
|
Description |
A universal data type for computations which may fail. Errors are reported
using extensible exceptions. These exceptions are not explicitly stated; if
you want this kind of functionality, something like control-monad-exception
might be a more appropriate fit.
|
|
Synopsis |
|
|
|
|
Data type and type class
|
|
|
Contains either a Success value or a Failure exception.
| Constructors | | Instances | |
|
|
class FromAttempt a where | Source |
|
|
|
|
A shortcut for fromAttempt.
|
|
|
This is not a simple translation of the Control.Monad.join function.
Instead, for Monads which are instances of FromAttempt, it removes the
inner Attempt type, reporting errors as defined in the FromAttempt
instance.
For example, join (Just (failureString "foo")) == Nothing.
|
|
General handling of Attempts
|
|
|
:: | | => forall e. Exception e => e -> b | success handler
| -> a -> b | | -> Attempt a | | -> b | | Process either the exception or value in an Attempt to produce a result.
This function is modeled after maybe and either. The first argument must
accept any instances of Exception. If you want to handle multiple types
of exceptions, see makeHandler. The second argument converts the success
value.
Note that this function does not expose all the data available in an
Attempt value. Notably, the monadic stack trace is not passed on to the
error handler. If desired, use the monadicStackTrace function to extract
it.
|
|
|
|
Convert multiple AttemptHandlers and a default value into an exception
handler.
This is a convenience function when you want to have special handling for a
few types of Exceptions and provide another value for anything else.
|
|
|
A simple wrapper value necesary due to the Haskell type system. Wraps a
function from a *specific* Exception type to some value.
| Constructors | forall e . Exception e => AttemptHandler (e -> v) | |
|
|
|
Individual Attempts
|
|
|
Tests for a Failure value.
|
|
|
Tests for a Success value.
|
|
|
This is an unsafe, partial function which should only be used if you
either know that a function will succeed or don't mind the occassional
runtime exception.
|
|
Lists of Attempts
|
|
|
Returns only the Success values.
|
|
|
Returns only the Failure values, each wrapped in a SomeException.
|
|
|
Return all of the Failures and Successes separately in a tuple.
|
|
Runtime exceptions
|
|
|
Catches runtime (ie, IO) exceptions and inserts them into an Attempt.
Like handle, the first argument to this function must explicitly state the
type of its input.
|
|
Reexport the Failure class
|
|
module Control.Failure |
|
Produced by Haddock version 2.6.0 |