HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Moduletransformers-0.6.3.0Haskell2010

Control.Monad.Trans.Writer.Strict

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; for a lazy version with the same interface, see Control.Monad.Trans.Writer.Lazy. Although the output is built strictly, it is not possible to achieve constant space behaviour with this transformer: for that, use Control.Monad.Trans.Writer.CPS instead.

Contents
  1. The Writer monad
  2. The WriterT monad transformer
  3. Writer operations
  4. Lifting other operations
Synopsis

The Writer monad

The WriterT monad transformer

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

Constructors

Instances23MonadTrans, Monad, Functor, MonadFix, MonadFail, Applicative, …

Writer operations

Lifting other operations