bluefin-0.6.0.0: The Bluefin effect system
Safe HaskellNone
LanguageHaskell2010

Bluefin.Capability.Tell

Synopsis

Documentation

In most cases you'll probably prefer Yield to Tell, but Tell can still be useful in some cases, for example with Data.Monoid.Any to determine whether an event ever occurred.

Capability

Handlers

runTell Source #

Arguments

:: forall w (es :: Effects) r. Monoid w 
=> (forall (e :: Effects). Tell w e -> Eff (e :& es) r)

͘

-> Eff es (r, w) 
>>> getAny $ snd $ runPureEff $ runTell $ \w -> do
      -- Non-empty list (the tell event does happen)
      for_ [1 .. 10] $ \_ -> tell w (Any True)
True

execTell Source #

Arguments

:: forall w (es :: Effects) r. Monoid w 
=> (forall (e :: Effects). Tell w e -> Eff (e :& es) r)

͘

-> Eff es w 
>>> getAny $ runPureEff $ execTell $ \w -> do
      -- Non-empty list (the tell event does happen)
      for_ [1 .. 10] $ \_ -> tell w (Any True)
True
>>> getAny $ runPureEff $ execTell $ \w -> do
      -- Empty list (the tell event does not happen)
      for_ [] $ \_ -> tell w (Any True)
False

Effectful operations

tell Source #

Arguments

:: forall (e :: Effects) (es :: Effects) w. e <: es 
=> Writer w e 
-> w

͘

-> Eff es () 
>>> getAny $ runPureEff $ execWriter $ \w -> do
      -- Non-empty list (the tell event does happen)
      for_ [1 .. 10] $ \_ -> tell w (Any True)
True