Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Labeled effects.
Since: 2.3.0.0
Example
An effect can be assigned multiple labels and you can have all of them available at the same time.
>>>
import Effectful.Reader.Static
>>>
:{
action :: ( Labeled "a" (Reader String) :> es , Labeled "b" (Reader String) :> es , Reader String :> es ) => Eff es String action = do a <- labeled @"b" @(Reader String) $ do labeled @"a" @(Reader String) $ do ask b <- labeled @"b" @(Reader String) $ do ask pure $ a ++ b :}
>>>
:{
runPureEff @String . runLabeled @"a" (runReader "a") . runLabeled @"b" (runReader "b") . runReader "c" $ action :} "ab"
Effect
data Labeled (label :: k) (e :: Effect) :: Effect Source #
Assign a label to an effect.
Instances
type DispatchOf (Labeled label e) Source # | |
Defined in Effectful.Labeled | |
data StaticRep (Labeled label e) Source # | |
Defined in Effectful.Labeled |
Handlers
:: forall label e es a b. (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.