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

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Writer

Synopsis

Documentation

class (Monoid w, MemberEffect Writer (Writer w) l) => EffectWriter w l Source

Instances

(Monoid w, MemberEffect (* -> * -> *) Writer (Writer w) l) => EffectWriter w l 

data Writer w a Source

An effect that allows accumulating output.

Instances

Functor (Writer w) 
type Is (* -> * -> *) Writer f 

runWriter :: Monoid w => Effect (Writer w :+ l) a -> Effect l (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 l => w -> Effect l () Source

Writes a value to the output.

listen :: EffectWriter w l => Effect l a -> Effect l (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 l => (w -> b) -> Effect l a -> Effect l (a, b) Source

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

pass :: EffectWriter w l => Effect l (a, w -> w) -> Effect l 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 l => (w -> w) -> Effect l a -> Effect l a Source

Applies a function to the writer output of a computation.

stateWriter :: (Monoid s, EffectState s l) => Effect (Writer s :+ l) a -> Effect l a Source

Executes a writer computation which sends its output to a state effect.