cleff-0.2.0.0: Fast and concise extensible effects
Copyright(c) 2021 Xy Ren
LicenseBSD3
Maintainerxy.r@outlook.com
Stabilityexperimental
Portabilitynon-portable (GHC only)
Safe HaskellTrustworthy
LanguageHaskell2010

Cleff.Mask

Description

 
Synopsis

Effect

data Mask :: Effect where Source #

An effect capable of masking and specifically, bracketing operations, i.e. allowing cleanup after operations that my raise exceptions.

Constructors

Mask :: ((m ~> m) -> m a) -> Mask m a 
UninterruptibleMask :: ((m ~> m) -> m a) -> Mask m a 
Bracket :: m a -> (a -> m c) -> (a -> m b) -> Mask m b 
BracketOnError :: m a -> (a -> m c) -> (a -> m b) -> Mask m b 

Operations

mask :: Mask :> es => ((~>) (Eff es) (Eff es) -> Eff es a) -> Eff es a Source #

uninterruptibleMask :: Mask :> es => ((~>) (Eff es) (Eff es) -> Eff es a) -> Eff es a Source #

bracket :: Mask :> es => Eff es a -> (a -> Eff es c) -> (a -> Eff es b) -> Eff es b Source #

bracketOnError :: Mask :> es => Eff es a -> (a -> Eff es c) -> (a -> Eff es b) -> Eff es b Source #

mask_ :: Mask :> es => Eff es a -> Eff es a Source #

Variant of mask that does not provide a restoring function.

uninterruptibleMask_ :: Mask :> es => Eff es a -> Eff es a Source #

Variant of uninterruptibleMask that does not provide a restoring function.

bracket_ :: Mask :> es => Eff es a -> Eff es c -> (a -> Eff es b) -> Eff es b Source #

Variant of bracket that does not pass the allocated resource to the cleanup action.

finally :: Mask :> es => Eff es a -> Eff es b -> Eff es a Source #

Attach a cleanup action that will always run to a potentially throwing computation.

onError :: Mask :> es => Eff es a -> Eff es b -> Eff es a Source #

Attach an action that runs if the main computation throws an exception.

Interpretations

runMask :: Eff (Mask ': es) ~> Eff es Source #

Interpret the Mask effect in terms of primitive IO actions.