cleff-0.1.0.0: Fast and concise extensible effects
Safe HaskellNone
LanguageHaskell2010

Cleff.Writer

Synopsis

Effect

data Writer w :: Effect where Source #

An effect capable of accumulating outputs. This roughly corresponds to the MonadWriter typeclass and WriterT monad transformer in the mtl approach.

However, note that this does not have a pass operation as we are not sure what its semantics should be. In fact, the pass semantics in mtl is also unclear and will change when handlers are put in different orders. To avoid any confusion we decided it is best that we don't include it because no one seems to be relying on it anyway.

Constructors

Tell :: w -> Writer w m () 
Listen :: m a -> Writer w m (a, w) 

Operations

tell :: Writer w :> es => w -> Eff es () Source #

listen :: Writer w :> es => Eff es a -> Eff es (a, w) Source #

listens :: Writer w :> es => (w -> x) -> Eff es a -> Eff es (a, x) Source #

Apply a function to the accumulated output of listen.

Interpretations

runWriter :: forall w es a. Monoid w => Eff (Writer w ': es) a -> Eff es (a, w) Source #

Run a monoidal Writer effect.

Caveat: Both runWriter and listens under runWriter will stop taking care of writer operations done on forked threads as soon as the main thread finishes its computation. Any writer operation done before main thread finishes is still taken into account.