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

  • Packagepolysemy-1.9.2.0
  • Exports14
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceWriter.hs

Effect

datadata Writer o (m :: Type -> Type) a where

An effect capable of emitting and intercepting messages.

Constructors

  • Tell :: o -> Writer o m ()

    Write a message to the log.

  • Listen :: m a -> Writer o m a

    Return the log produced by the higher-order action.

  • Pass :: m (o -> o, a) -> Writer o m a

    Run the given action and apply the function it returns to the log.

Actions

valuepass :: Member (Writer o) r => Sem r (o -> o, a) -> Sem r a
#

Run the given action and apply the function it returns to the log.

Interpretations

valuewriterToIOAssocRFinal
  1. :: (Monoid o, Member (Final IO) r)
  2. => Sem (Writer o ': r) a
  3. -> Sem r (o, a)

Like writerToIOFinal. but right-associates uses of <>.

This asymptotically improves performance if the time complexity of <> for the Monoid depends only on the size of the first argument.

You should always use this instead of writerToIOFinal if the monoid is a list, such as String.

Beware: Effects that aren't interpreted in terms of IO will have local state semantics in regards to Writer effects interpreted this way. See Final.

Interpretations for Other Effects