polysemy-conc-0.8.0.1: Polysemy Effects for Concurrency
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Conc.Effect.Scoped

Description

 
Synopsis

Documentation

data Scoped (resource :: Type) (effect :: Effect) :: Effect where Source #

Scoped transforms a program so that effect is associated with a resource within that program. This requires the interpreter for effect to be parameterized by resource and constructed for every program using Scoped separately.

An application for this is Events, in which each program using the effect Consume is interpreted with its own copy of the event channel; or a database transaction, in which a transaction handle is created for the wrapped program and passed to the interpreter for the database effect.

Resource creation is performed by the function passed to runScoped.

The constructors are not intended to be used directly; the smart constructor scoped is used like a local interpreter for effect.

Constructors

Run :: forall resource effect m a. resource -> effect m a -> Scoped resource effect m a 
InScope :: forall resource effect m a. (resource -> m a) -> Scoped resource effect m a 

scoped :: forall resource effect r. Member (Scoped resource effect) r => InterpreterFor effect r Source #

Constructor for Scoped, taking a nested program and transforming all instances of effect to Scoped resource effect.