monad-peel-0.2.1: Lift control operations like exception catching through monad transformers

Copyright© Anders Kaseorg, 2010
LicenseBSD-style
MaintainerAnders Kaseorg <andersk@mit.edu>
Stabilityexperimental
Portabilitynon-portable (extended exceptions)
Safe HaskellSafe
LanguageHaskell98

Control.Exception.Peel

Description

This is a wrapped version of Control.Exception with types generalized from IO to all monads in MonadPeelIO.

Synopsis

Documentation

throwIO :: (MonadIO m, Exception e) => e -> m a Source

Generalized version of throwIO.

ioError :: MonadIO m => IOError -> m a Source

Generalized version of ioError.

catch Source

Arguments

:: (MonadPeelIO 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 :: MonadPeelIO m => m a -> [Handler m a] -> m a Source

Generalized version of catches.

data Handler m a Source

Generalized version of Handler.

Constructors

forall e . Exception e => Handler (e -> m a) 

catchJust Source

Arguments

:: (MonadPeelIO 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.

handle :: (MonadPeelIO m, Exception e) => (e -> m a) -> m a -> m a Source

Generalized version of handle.

handleJust :: (MonadPeelIO m, Exception e) => (e -> Maybe b) -> (b -> m a) -> m a -> m a Source

Generalized version of handleJust.

try :: (MonadPeelIO m, Exception e) => m a -> m (Either e a) Source

Generalized version of try.

tryJust :: (MonadPeelIO m, Exception e) => (e -> Maybe b) -> m a -> m (Either b a) Source

Generalized version of tryJust.

evaluate :: MonadIO m => a -> m a Source

Generalized version of evaluate.

bracket Source

Arguments

:: MonadPeelIO 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_ :: MonadPeelIO m => m a -> m b -> m c -> m c Source

Generalized version of bracket_. Note, any monadic side effects in m of both the "acquire" and "release" computations will be discarded. To keep the monadic side effects of the "acquire" computation, use bracket with constant functions instead.

bracketOnError Source

Arguments

:: MonadPeelIO 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.

finally Source

Arguments

:: MonadPeelIO 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 :: MonadPeelIO m => m a -> m b -> m a Source

Generalized version of onException.