{-# options_haddock prune #-}
module Polysemy.Conc.Effect.Mask where
import Polysemy.Conc.Effect.Scoped (Scoped, scoped)
data RestoreMask :: Effect where
Restore :: m a -> RestoreMask m a
makeSem_ ''RestoreMask
restore ::
∀ r a .
Member RestoreMask r =>
Sem r a ->
Sem r a
newtype MaskResource resource =
MaskResource { forall resource. MaskResource resource -> resource
unMaskResource :: resource }
newtype UninterruptibleMaskResource resource =
UninterruptibleMaskResource { forall resource. UninterruptibleMaskResource resource -> resource
unUninterruptibleMaskResource :: resource }
type Mask resource =
Scoped (MaskResource resource) RestoreMask
type UninterruptibleMask resource =
Scoped (UninterruptibleMaskResource resource) RestoreMask
mask ::
∀ resource r .
Member (Mask resource) r =>
InterpreterFor RestoreMask r
mask :: forall resource (r :: [(* -> *) -> * -> *]).
Member (Mask resource) r =>
InterpreterFor RestoreMask r
mask =
forall resource (effect :: (* -> *) -> * -> *)
(r :: [(* -> *) -> * -> *]).
Member (Scoped resource effect) r =>
InterpreterFor effect r
scoped @(MaskResource resource)
uninterruptibleMask ::
∀ resource r .
Member (UninterruptibleMask resource) r =>
InterpreterFor RestoreMask r
uninterruptibleMask :: forall resource (r :: [(* -> *) -> * -> *]).
Member (UninterruptibleMask resource) r =>
InterpreterFor RestoreMask r
uninterruptibleMask =
forall resource (effect :: (* -> *) -> * -> *)
(r :: [(* -> *) -> * -> *]).
Member (Scoped resource effect) r =>
InterpreterFor effect r
scoped @(UninterruptibleMaskResource resource)