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

Moduleeffectful-core-2.3.0.1Haskell2010

Effectful.Writer.Static.Local

Support for access to a write only value of a particular type.

The value is thread local. If you want it to be shared between threads, use Effectful.Writer.Static.Shared.

Warning: Writer's state will be accumulated via left-associated uses of <>, which makes it unsuitable for use with types for which such pattern is inefficient. This applies, in particular, to the standard list type, which makes the Writer effect pretty niche.

Note: while the Writer from the transformers package includes additional operations pass and censor, they don't cooperate with runtime exceptions very well, so they're deliberately omitted here.

  • 1 type
  • 5 values

Effect

1 declaration
datadata Writer w (a :: Type -> Type) b
#

Provide access to a strict (WHNF), thread local, write only value of type w.

Instances2DispatchOf, StaticRep

Handlers

Operations

valuelisten :: (Writer w :> es, Monoid w) => Eff es a -> Eff es (a, w)
#

Execute an action and append its output to the overall output of the Writer.

Note: if an exception is received while the action is executed, the partial output of the action will still be appended to the overall output of the Writer:

Example1 expression
:{  runEff . execWriter @String $ do    tell "Hi"    handle (\(_::ErrorCall) -> pure ((), "")) $ do      tell " there"      listen $ do        tell "!"        error "oops":}"Hi there!"