Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Effect.Bracket
- class MemberEffect Bracket (Bracket s) l => EffectBracket s l
- data Bracket s a
- runBracket :: (forall s. Effect (Bracket s :+ l) a) -> Effect l a
- data Tag s a
- newTag :: EffectBracket s l => (a -> String) -> Effect l (Tag s a)
- raiseWith :: EffectBracket s l => Tag s b -> b -> Effect l a
- exceptWith :: EffectBracket s l => Tag s b -> Effect l a -> (b -> Effect l a) -> Effect l a
- data Handler s l a
- exceptAny :: EffectBracket s l => Effect l a -> [Handler s l a] -> Effect l a
- bracket :: EffectBracket s l => Effect l a -> (a -> Effect l ()) -> (a -> Effect l b) -> Effect l b
- finally :: EffectBracket s l => Effect l a -> Effect l () -> Effect l a
Documentation
class MemberEffect Bracket (Bracket s) l => EffectBracket s l Source #
Instances
MemberEffect (* -> * -> *) Bracket (Bracket s) l => EffectBracket s l Source # | |
Provides a base effect for exceptions. This effect allows the dynamic generation of exception classes at runtime.
The type of placeholder values indicating an exception class.
Instances
TestEquality * (Tag s) Source # | |
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.
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
.
Arguments
:: EffectBracket s l | |
=> Effect l a | The |
-> (a -> Effect l ()) | The |
-> (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.