effectful-core-2.4.0.0: An easy to use, performant extensible effects library.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Effectful.Labeled

Description

Labeled effects.

Any effect can be assigned multiple labels so you have more than one available simultaneously.

Since: 2.3.0.0

Synopsis

Effect

newtype Labeled (label :: k) (e :: Effect) :: Effect where Source #

Assign a label to an effect.

The constructor is for sending labeled operations of a dynamically dispatched effect to the handler:

>>> import Effectful.Dispatch.Dynamic
>>> :{
  data X :: Effect where
    X :: X m Int
  type instance DispatchOf X = Dynamic
:}
>>> :{
  runPureEff . runLabeled @"x" (interpret_ $ \X -> pure 333) $ do
    send $ Labeled @"x" X
:}
333

Constructors

Labeled :: forall label e m a. e m a -> Labeled label e m a

Since: 2.4.0.0

Instances

Instances details
type DispatchOf (Labeled label e) Source # 
Instance details

Defined in Effectful.Labeled

type DispatchOf (Labeled label e) = DispatchOf e
data StaticRep (Labeled label e) Source # 
Instance details

Defined in Effectful.Labeled

data StaticRep (Labeled label e)

Handlers

runLabeled Source #

Arguments

:: forall label e es a b. HasCallStack 
=> (Eff (e : es) a -> Eff es b)

The effect handler.

-> Eff (Labeled label e : es) a 
-> Eff es b 

Run a Labeled effect with a given effect handler.

Operations

labeled Source #

Arguments

:: forall label e es a. (HasCallStack, Labeled label e :> es) 
=> Eff (e : es) a

The action using the effect.

-> Eff es a 

Bring an effect into scope without a label.

Useful for running code written with the non-labeled effect in mind.