effin-0.3.0.3: A Typeable-free implementation of extensible effects

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Bracket

Synopsis

Documentation

class MemberEffect Bracket (Bracket s) l => EffectBracket s l Source #

Instances

data Bracket s a Source #

Provides a base effect for exceptions. This effect allows the dynamic generation of exception classes at runtime.

Instances

type Is (* -> * -> *) Bracket f Source # 
type Is (* -> * -> *) Bracket f

runBracket :: (forall s. Effect (Bracket s :+ l) a) -> Effect l a Source #

Executes a Bracket effect. The Rank-2 type ensures that Tags do not escape their scope.

data Tag s a Source #

The type of placeholder values indicating an exception class.

Instances

TestEquality * (Tag s) Source # 

Methods

testEquality :: f a -> f b -> Maybe ((Tag s :~: a) b) #

newTag :: EffectBracket s l => (a -> String) -> Effect l (Tag s a) Source #

Creates a new tag. The function parameter describes the error message that is shown in the case of an uncaught exception.

raiseWith :: EffectBracket s l => Tag s b -> b -> Effect l a Source #

Raises an exception of the specified class and value.

exceptWith :: EffectBracket s l => Tag s b -> Effect l a -> (b -> Effect l a) -> Effect l a Source #

Specifies a handler for exceptions of a given class.

data Handler s l a Source #

A handler for an exception. Use with exceptAny.

exceptAny :: EffectBracket s l => Effect l a -> [Handler s l a] -> Effect l a Source #

Specifies a number of handlers for exceptions thrown by the given computation. This is prefered over chained calles to exceptWith, i.e.

exceptWith t2 (exceptWith t1 m h1) h2

because h2 could catch exceptions thrown by h1.

bracket Source #

Arguments

:: EffectBracket s l 
=> Effect l a

The acquire operation.

-> (a -> Effect l ())

The release operation.

-> (a -> Effect l b)

The computation to perform.

-> Effect l b 

Executes a computation with a resource, and ensures that the resource is cleaned up afterwards.

finally :: EffectBracket s l => Effect l a -> Effect l () -> Effect l a Source #

A specialized version of bracket which does not require an acquire operation.