{-# options_haddock prune #-}
module Polysemy.Conc.Effect.Mask where
import Polysemy (makeSem_)
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 { MaskResource resource -> resource
unMaskResource :: resource }
newtype UninterruptipleMaskResource resource =
UninterruptipleMaskResource { UninterruptipleMaskResource resource -> resource
unUninterruptipleMaskResource :: resource }
type Mask resource =
Scoped (MaskResource resource) RestoreMask
type UninterruptipleMask resource =
Scoped (UninterruptipleMaskResource resource) RestoreMask
mask ::
∀ resource r .
Member (Mask resource) r =>
InterpreterFor RestoreMask r
mask :: InterpreterFor RestoreMask r
mask =
forall resource (effect :: Effect) (r :: [Effect]).
Member (Scoped resource effect) r =>
InterpreterFor effect r
forall (effect :: Effect) (r :: [Effect]).
Member (Scoped (MaskResource resource) effect) r =>
InterpreterFor effect r
scoped @(MaskResource resource)
uninterruptibleMask ::
∀ resource r .
Member (UninterruptipleMask resource) r =>
InterpreterFor RestoreMask r
uninterruptibleMask :: InterpreterFor RestoreMask r
uninterruptibleMask =
forall resource (effect :: Effect) (r :: [Effect]).
Member (Scoped resource effect) r =>
InterpreterFor effect r
forall (effect :: Effect) (r :: [Effect]).
Member (Scoped (UninterruptipleMaskResource resource) effect) r =>
InterpreterFor effect r
scoped @(UninterruptipleMaskResource resource)