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

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Writer

Contents

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 Source # 

data Writer w a Source #

An effect that allows accumulating output.

Instances

type Is (* -> * -> *) Writer f Source # 
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.

Orphan instances

(Monoid w, Member (* -> *) (Writer w) l, (~) (* -> *) (Writer w) (InstanceOf (* -> * -> *) Writer l)) => MonadWriter w (Effect l) Source # 

Methods

writer :: (a, w) -> Effect l a #

tell :: w -> Effect l () #

listen :: Effect l a -> Effect l (a, w) #

pass :: Effect l (a, w -> w) -> Effect l a #