effin-0.1.0.0: A Typeable-free implementation of extensible effects

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Writer

Synopsis

Documentation

type EffectWriter w es = (Monoid w, Member (Writer w) es, w ~ WriterType es) Source

data Writer w a Source

An effect that allows accumulating output.

Instances

runWriter :: Monoid w => Effect (Writer w : es) a -> Effect es (a, w) Source

Completely handles a writer effect. The writer value must be a Monoid. mempty is used as an initial value, and mappend is used to combine values. Returns the result of the computation and the final output value.

tell :: EffectWriter w es => w -> Effect es () Source

Writes a value to the output.

listen :: EffectWriter w es => Effect es a -> Effect es (a, w) Source

Executes a computation, and obtains the writer output. The writer output of the inner computation is still written to the writer output of the outer computation.

listens :: EffectWriter w es => (w -> b) -> Effect es a -> Effect es (a, b) Source

Like listen, but the writer output is run through a function.

pass :: EffectWriter w es => Effect es (a, w -> w) -> Effect es a Source

Runs a computation that returns a value and a function, applies the function to the writer output, and then returns the value.

censor :: EffectWriter w es => (w -> w) -> Effect es a -> Effect es a Source

Applies a function to the writer output of a computation.