in-other-words-0.1.0.0: A higher-order effect system where the sky's the limit

Control.Effect.Type.Bracket

Contents

Synopsis

Effects

data Bracket m a where Source #

An effect for exception-safe acquisition and release of resources.

Bracket is typically used as a primitive effect. If you define a Carrier that relies on a novel non-trivial monad transformer t, then you need to make a ThreadsEff t Bracket instance (if possible). threadBracketViaClass can help you with that.

The following threading constraints accept Bracket:

• ReaderThreads
• StateThreads
• StateLazyThreads
• ErrorThreads
• WriterThreads
• WriterLazyThreads

Constructors

 GeneralBracket :: m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> Bracket m (b, c)

Instances

Instances details

data ExitCase a #

A MonadMask computation may either succeed with a value, abort with an exception, or abort for some other reason. For example, in ExceptT e IO you can use throwM to abort with an exception (ExitCaseException) or throwE to abort with a value of type e (ExitCaseAbort).

Constructors

 ExitCaseSuccess a ExitCaseException SomeException ExitCaseAbort

Instances

Instances details
 Show a => Show (ExitCase a) Instance detailsDefined in Control.Monad.Catch MethodsshowsPrec :: Int -> ExitCase a -> ShowS #show :: ExitCase a -> String #showList :: [ExitCase a] -> ShowS #

A valid definition of threadEff for a ThreadsEff t Bracket instance, given that t lifts MonadMask.
BEWARE: threadBracketViaClass is only safe if the implementation of generalBracket for t m only makes use of generalBracket for m, and no other methods of MonadThrow, MonadCatch, or MonadMask.