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

Moduletransformers-0.6.1.1Haskell2010

Control.Monad.Trans.Writer.CPS

The strict WriterT monad transformer, which adds collection of outputs (such as a count or string output) to a given monad.

This monad transformer provides only limited access to the output during the computation. For more general access, use Control.Monad.Trans.State instead.

This version builds its output strictly and uses continuation-passing-style to achieve constant space usage. This transformer can be used as a drop-in replacement for Control.Monad.Trans.Writer.Strict.

  • 2 types
  • 15 values

The Writer monad

5 declarations

The WriterT monad transformer

5 declarations
newtypenewtype WriterT w (m :: Type -> Type) a
#

A writer monad parameterized by:

  • w - the output to accumulate.

  • m - The inner monad.

The return function produces the output mempty, while m >>= k combines the outputs of the subcomputations using mappend (also known as <>):

image: images/bind-WriterT.svg

Instances11MonadTrans, Monad, Functor, MonadFix, MonadFail, Applicative, …

Writer operations

5 declarations

Lifting other operations

2 declarations
valueliftCallCC :: CallCC m (a, w) (b, w) -> CallCC (WriterT w m) a b
#

Uniform lifting of a callCC operation to the new monad. This version rolls back to the original state on entering the continuation.