{-# options_haddock prune #-}
module Polysemy.Conc.Effect.Scoped where
data Scoped (resource :: Type) (effect :: Effect) :: Effect where
Run :: ∀ resource effect m a . resource -> effect m a -> Scoped resource effect m a
InScope :: ∀ resource effect m a . (resource -> m a) -> Scoped resource effect m a
scoped ::
∀ resource effect r .
Member (Scoped resource effect) r =>
InterpreterFor effect r
scoped :: forall resource (effect :: Effect) (r :: [Effect]).
Member (Scoped resource effect) r =>
InterpreterFor effect r
scoped Sem (effect : r) a
main =
Scoped resource effect (Sem r) a -> Sem r a
forall (e :: Effect) (r :: [Effect]) a.
Member e r =>
e (Sem r) a -> Sem r a
send (Scoped resource effect (Sem r) a -> Sem r a)
-> Scoped resource effect (Sem r) a -> Sem r a
forall a b. (a -> b) -> a -> b
$ forall resource (effect :: Effect) (m :: * -> *) a.
(resource -> m a) -> Scoped resource effect m a
InScope @resource @effect \ resource
resource ->
forall (e1 :: Effect) (e2 :: Effect) (r :: [Effect]) a.
Member e2 r =>
(forall (rInitial :: [Effect]) x.
e1 (Sem rInitial) x -> e2 (Sem rInitial) x)
-> Sem (e1 : r) a -> Sem r a
transform @effect (resource
-> effect (Sem rInitial) x
-> Scoped resource effect (Sem rInitial) x
forall resource (effect :: Effect) (m :: * -> *) a.
resource -> effect m a -> Scoped resource effect m a
Run resource
resource) Sem (effect : r) a
main