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

Safe HaskellNone
LanguageHaskell2010

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:

Constructors

GeneralBracket :: m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> Bracket m (b, c) 
Instances
ThreadsEff (ExceptT e) Bracket Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

threadEff :: Monad m => (forall x. Bracket m x -> m x) -> Bracket (ExceptT e m) a -> ExceptT e m a Source #

Monoid s => ThreadsEff (WriterT s) Bracket Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

threadEff :: Monad m => (forall x. Bracket m x -> m x) -> Bracket (WriterT s m) a -> WriterT s m a Source #

ThreadsEff (StateT s) Bracket Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

threadEff :: Monad m => (forall x. Bracket m x -> m x) -> Bracket (StateT s m) a -> StateT s m a Source #

ThreadsEff (ReaderT i) Bracket Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

threadEff :: Monad m => (forall x. Bracket m x -> m x) -> Bracket (ReaderT i m) a -> ReaderT i m a Source #

ThreadsEff (StateT s) Bracket Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

threadEff :: Monad m => (forall x. Bracket m x -> m x) -> Bracket (StateT s m) a -> StateT s m a Source #

Monoid s => ThreadsEff (WriterT s) Bracket Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

threadEff :: Monad m => (forall x. Bracket m x -> m x) -> Bracket (WriterT s m) a -> WriterT s m a Source #

Monoid s => ThreadsEff (WriterT s) Bracket Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

threadEff :: Monad m => (forall x. Bracket m x -> m x) -> Bracket (WriterT s m) a -> WriterT s m a Source #

Monad m => MonadThrow (ViaAlg s Bracket m) Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

throwM :: Exception e => e -> ViaAlg s Bracket m a #

Monad m => MonadCatch (ViaAlg s Bracket m) Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

catch :: Exception e => ViaAlg s Bracket m a -> (e -> ViaAlg s Bracket m a) -> ViaAlg s Bracket m a #

(Reifies s (ReifiedEffAlgebra Bracket m), Monad m) => MonadMask (ViaAlg s Bracket m) Source # 
Instance details

Defined in Control.Effect.Type.Bracket

Methods

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) #

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).

Instances
Show a => Show (ExitCase a) 
Instance details

Defined in Control.Monad.Catch

Methods

showsPrec :: Int -> ExitCase a -> ShowS #

show :: ExitCase a -> String #

showList :: [ExitCase a] -> ShowS #

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 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.