lio-0.1.3: Labeled IO Information Flow Control Library

Safe HaskellSafe

LIO.MonadCatch

Description

This module generalizes throw and catch (from Control.Exception) to methods that can be defined on multiple monads.

Synopsis

Documentation

class Monad m => MonadCatch m whereSource

MonadCatch is the class used to generalize the standard IO catch and throwIO functions to methods that can be defined in multiple monads. Minimal definition requires: mask, throwIO, catch, and onException.

Methods

maskSource

Arguments

:: ((forall a. m a -> m a) -> m b)

Function that takes a mask-restoring function as argument and returns an action to execute.

-> m b 

Executes a computation with asynchronous exceptions masked. See Control.Exception for more details.

mask_ :: m a -> m aSource

Like mask, but does not pass a restore action to the argument.

throwIO :: Exception e => e -> m aSource

A variant of throwIO that can be used within the monad.

catchSource

Arguments

:: Exception e 
=> m a

Computation to run

-> (e -> m a)

Handler

-> m a 

Simplest exception-catching function.

handle :: Exception e => (e -> m a) -> m a -> m aSource

Version of catch with the arguments swapped around.

onExceptionSource

Arguments

:: m a

Computation to run first

-> m b

Computation to run after, if an exception was raised.

-> m a 

Performs an action and a subsequent action if an exceptino is raised.

bracketSource

Arguments

:: m b

Computation to run first

-> (b -> m c)

Computation to run last

-> (b -> m a)

Computation to run in-between

-> m a 

This function allows you to execute an action with an initial "acquire resource" and final "release resource" as bracket of Control.Exception.

bracket_ :: m a -> m b -> m c -> m cSource

Variant of bracket where the return value from the first computation is not required.

finallySource

Arguments

:: m a

Computation to run first

-> m b

Computation to run after

-> m a 

Performs an action and a subsequent action.

Instances

MonadCatch IO 
LabelState l p s => MonadCatch (LIO l p s) 

genericBracketSource

Arguments

:: MonadCatch m 
=> (m b -> m c -> m b)

On exception function

-> m a

Action to perform first

-> (a -> m c)

Action to perform last

-> (a -> m b)

Action to perform in-between

-> m b

Result of in-between action

Given some general onException function, genericBracket allows you to execute an action with an initial "acquire resource" and final "release resource" as bracket of Control.Exception.