Portability | non-portable (extended exceptions) |
---|---|
Stability | experimental |
Maintainer | Bas van Dijk <v.dijk.bas@gmail.com> |
This is a wrapped version of Control.Exception
with types generalized
from IO
to all monads in MonadControlIO
.
- module Control.Exception
- throwIO :: (MonadIO m, Exception e) => e -> m a
- ioError :: MonadIO m => IOError -> m a
- catch :: (MonadControlIO m, Exception e) => m a -> (e -> m a) -> m a
- catches :: MonadControlIO m => m a -> [Handler m a] -> m a
- data Handler m a = forall e . Exception e => Handler (e -> m a)
- catchJust :: (MonadControlIO m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a
- handle :: (MonadControlIO m, Exception e) => (e -> m a) -> m a -> m a
- handleJust :: (MonadControlIO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a
- try :: (MonadControlIO m, Exception e) => m a -> m (Either e a)
- tryJust :: (MonadControlIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)
- evaluate :: MonadIO m => a -> m a
- mask :: MonadControlIO m => ((forall a. m a -> m a) -> m b) -> m b
- mask_ :: MonadControlIO m => m a -> m a
- uninterruptibleMask :: MonadControlIO m => ((forall a. m a -> m a) -> m b) -> m b
- uninterruptibleMask_ :: MonadControlIO m => m a -> m a
- getMaskingState :: MonadIO m => m MaskingState
- blocked :: MonadIO m => m Bool
- bracket :: MonadControlIO m => m a -> (a -> m b) -> (a -> m c) -> m c
- bracket_ :: MonadControlIO m => m a -> m b -> m c -> m c
- bracketOnError :: MonadControlIO m => m a -> (a -> m b) -> (a -> m c) -> m c
- finally :: MonadControlIO m => m a -> m b -> m a
- onException :: MonadControlIO m => m a -> m b -> m a
Documentation
module Control.Exception
Throwing exceptions
Catching exceptions
The catch
functions
:: (MonadControlIO m, Exception e) | |
=> m a | The computation to run |
-> (e -> m a) | Handler to invoke if an exception is raised |
-> m a |
Generalized version of catch
.
catches :: MonadControlIO m => m a -> [Handler m a] -> m aSource
Generalized version of catches
.
:: (MonadControlIO m, Exception e) | |
=> (e -> Maybe b) | Predicate to select exceptions |
-> m a | Computation to run |
-> (b -> m a) | Handler |
-> m a |
Generalized version of catchJust
.
The handle
functions
handle :: (MonadControlIO m, Exception e) => (e -> m a) -> m a -> m aSource
Generalized version of handle
.
handleJust :: (MonadControlIO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m aSource
Generalized version of handleJust
.
The try
functions
tryJust :: (MonadControlIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a)Source
Generalized version of tryJust
.
The evaluate
function
Asynchronous Exceptions
Asynchronous exception control
The following functions allow a thread to control delivery of asynchronous exceptions during a critical region.
mask :: MonadControlIO m => ((forall a. m a -> m a) -> m b) -> m bSource
Generalized version of mask
.
mask_ :: MonadControlIO m => m a -> m aSource
Generalized version of mask_
.
uninterruptibleMask :: MonadControlIO m => ((forall a. m a -> m a) -> m b) -> m bSource
Generalized version of uninterruptibleMask
.
uninterruptibleMask_ :: MonadControlIO m => m a -> m aSource
Generalized version of uninterruptibleMask_
.
getMaskingState :: MonadIO m => m MaskingStateSource
Generalized version of getMaskingState
.
blocked :: MonadIO m => m BoolSource
Generalized version of blocked
.
returns True
if asynchronous exceptions are blocked in the
current thread.
Utilities
:: MonadControlIO m | |
=> m a | computation to run first ("acquire resource") |
-> (a -> m b) | computation to run last ("release resource") |
-> (a -> m c) | computation to run in-between |
-> m c |
Generalized version of bracket
. Note, any monadic side
effects in m
of the "release" computation will be discarded; it
is run only for its side effects in IO
.
bracket_ :: MonadControlIO m => m a -> m b -> m c -> m cSource
:: MonadControlIO m | |
=> m a | computation to run first ("acquire resource") |
-> (a -> m b) | computation to run last ("release resource") |
-> (a -> m c) | computation to run in-between |
-> m c |
Generalized version of bracketOnError
. Note, any monadic side
effects in m
of the "release" computation will be discarded.
:: MonadControlIO m | |
=> m a | computation to run first |
-> m b | computation to run afterward (even if an exception was raised) |
-> m a |
Generalized version of finally
. Note, any monadic side
effects in m
of the "afterward" computation will be discarded.
onException :: MonadControlIO m => m a -> m b -> m aSource
Generalized version of onException
. Note, any monadic side
effects in m
of the "afterward" computation will be discarded.