extensible-effects-2.4.0.0: An Alternative to Monad Transformers

Safe HaskellSafe
LanguageHaskell2010

Control.Eff.Writer.Strict

Description

Strict write-only state

Synopsis

Documentation

data Writer w v where Source #

The Writer monad

In MTL's Writer monad, the told value must have a |Monoid| type. Our writer has no such constraints. If we write a |Writer|-like interpreter to accumulate the told values in a monoid, it will have the |Monoid w| constraint then

Constructors

Tell :: !w -> Writer w () 

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

Write a new value.

censor :: forall w a r. Member (Writer w) r => (w -> w) -> Eff r a -> Eff r a Source #

Transform the state being produced.

runWriter :: (w -> b -> b) -> b -> Eff (Writer w ': r) a -> Eff r (a, b) Source #

Handle Writer requests, using a user-provided function to accumulate values, hence no Monoid constraints.

runFirstWriter :: Eff (Writer w ': r) a -> Eff r (a, Maybe w) Source #

Handle Writer requests by taking the first value provided.

runLastWriter :: Eff (Writer w ': r) a -> Eff r (a, Maybe w) Source #

Handle Writer requests by overwriting previous values.

runListWriter :: Eff (Writer w ': r) a -> Eff r (a, [w]) Source #

Handle Writer requests, using a List to accumulate values.

runMonoidWriter :: Monoid w => Eff (Writer w ': r) a -> Eff r (a, w) Source #

Handle Writer requests, using a Monoid instance to accumulate values.