Safe Haskell | None |
---|---|
Language | Haskell2010 |
Control.Effect.Writer
Contents
- class (Monoid w, MemberEffect Writer (Writer w) l) => EffectWriter w l
- data Writer w a
- runWriter :: Monoid w => Effect (Writer w :+ l) a -> Effect l (a, w)
- tell :: EffectWriter w l => w -> Effect l ()
- listen :: EffectWriter w l => Effect l a -> Effect l (a, w)
- listens :: EffectWriter w l => (w -> b) -> Effect l a -> Effect l (a, b)
- pass :: EffectWriter w l => Effect l (a, w -> w) -> Effect l a
- censor :: EffectWriter w l => (w -> w) -> Effect l a -> Effect l a
- stateWriter :: (Monoid s, EffectState s l) => Effect (Writer s :+ l) a -> Effect l a
Documentation
class (Monoid w, MemberEffect Writer (Writer w) l) => EffectWriter w l Source #
Instances
(Monoid w, MemberEffect (* -> * -> *) Writer (Writer w) l) => EffectWriter w l Source # | |
An effect that allows accumulating output.
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.