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 #
- https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Writer-Class.html
- Original Mark P Jones article introducing
Writer
Creates an instance of Monad, with an explicitly given empty and append operation.
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 ω]
.
Instances For
- adaptWriter : {α : Type u} → (ω → ω) → m α → m α
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
.
Instances
Transitivity.
see Note [lower instance priority]