HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulemonads-tf-0.3.0.1GHC2021

Control.Monad.Writer.Class

The MonadWriter class.

Inspired by the paper /Functional Programming with Overloading and Higher-Order Polymorphism/, Mark P Jones (http://web.cecs.pdx.edu/~mpj/pubs/springschool.html) Advanced School of Functional Programming, 1995.

  • 1 class
  • 2 values
classclass (Monoid (WriterType m), Monad m) => MonadWriter (m :: Type -> Type) where
#

Associated types

Methods

  • tell :: WriterType m -> m ()

    Shout to the monad what you want to be heard. The monad carries this packet upwards, merging it if needed (hence the Monoid requirement).

  • listen :: m a -> m (a, WriterType m)

    Listen to a monad acting, and return what the monad "said".

  • pass :: m (a, WriterType m -> WriterType m) -> m a

    Provide a writer transformer which changes internals of the written object.

Instances10MonadWriter, …
valuelistens :: MonadWriter m => (WriterType m -> b) -> m a -> m (a, b)
#

listens f m is an action that executes the action m and adds the result of applying f to the output to the value of the computation.