Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Bracket m a where
- GeneralBracket :: m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> Bracket m (b, c)
- data ExitCase a
- threadBracketViaClass :: forall t m a. Monad m => (RepresentationalT t, forall b. MonadMask b => MonadMask (t b)) => (forall x. Bracket m x -> m x) -> Bracket (t m) a -> t m a
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
instance (if possible).
ThreadsEff
t Bracket
threadBracketViaClass
can help you with that.
The following threading constraints accept Bracket
:
GeneralBracket :: m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> Bracket m (b, c) |
Instances
ThreadsEff (ExceptT e) Bracket Source # | |
Monoid s => ThreadsEff (WriterT s) Bracket Source # | |
ThreadsEff (StateT s) Bracket Source # | |
ThreadsEff (ReaderT i) Bracket Source # | |
ThreadsEff (StateT s) Bracket Source # | |
Monoid s => ThreadsEff (WriterT s) Bracket Source # | |
Monoid s => ThreadsEff (WriterT s) Bracket Source # | |
Monad m => MonadThrow (ViaAlg s Bracket m) Source # | |
Monad m => MonadCatch (ViaAlg s Bracket m) Source # | |
(Reifies s (ReifiedEffAlgebra Bracket m), Monad m) => MonadMask (ViaAlg s Bracket m) Source # | |
Defined in Control.Effect.Type.Bracket mask :: ((forall a. ViaAlg s Bracket m a -> ViaAlg s Bracket m a) -> ViaAlg s Bracket m b) -> ViaAlg s Bracket m b # uninterruptibleMask :: ((forall a. ViaAlg s Bracket m a -> ViaAlg s Bracket m a) -> ViaAlg s Bracket m b) -> ViaAlg s Bracket m b # generalBracket :: ViaAlg s Bracket m a -> (a -> ExitCase b -> ViaAlg s Bracket m c) -> (a -> ViaAlg s Bracket m b) -> ViaAlg s Bracket m (b, c) # |
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
).
Threading utilities
threadBracketViaClass :: forall t m a. Monad m => (RepresentationalT t, forall b. MonadMask b => MonadMask (t b)) => (forall x. Bracket m x -> m x) -> Bracket (t m) a -> t m a Source #
A valid definition of threadEff
for a
instance,
given that ThreadsEff
t Bracket
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
.