Writer monads #
This file introduces monads for managing immutable, appendable state. Common applications are logging monads where the monad logs messages as the computation progresses.
References #
Adds a writable output of type ω to a monad.
The instances on this type assume that either [Monoid ω] or [EmptyCollection ω] [Append ω].
Use WriterT.run to obtain the final value of this output.
Equations
Instances For
Equations
Instances For
- tell (w : ω) : M PUnit.{u + 1}
Emit an output
w. Capture the output produced by
f, without intercepting.Buffer the output produced by
fasw, then emit(← f).2 win its place.
Instances
Equations
Equations
Equations
Instances For
Equations
Instances For
Equations
Instances For
Creates an instance of Monad, with explicitly given empty and append operations.
Previously, this would have used an instance of [Monoid ω] as input.
In practice, however, WriterT is used for logging and creating lists so restricting to
monoids with Mul and One can make WriterT cumbersome to use.
This is used to derive instances for both [EmptyCollection ω] [Append ω] and [Monoid ω].
Equations
Instances For
Equations
Equations
Equations
Equations
Equations
Equations
Adapt a monad stack, changing the type of its top-most environment.
This class is comparable to Control.Lens.Magnify,
but does not use lenses (why would it), and is derived automatically for any transformer
implementing MonadFunctor.
- adaptWriter {α : Type u} : (ω → ω) → m α → m α
Instances
Transitivity.
see Note [lower instance priority]