HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulepolysemy-1.9.2.0Haskell2010

Polysemy.Output

  • 1 type
  • 14 values
  • Packagepolysemy-1.9.2.0
  • Exports15
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceOutput.hs

Effect

1 declaration
datadata Output o (m :: k) a where
#

An effect capable of sending messages. Useful for streaming output and for logging.

Constructors

Actions

1 declaration

Interpretations

13 declarations
valuerunLazyOutputList :: Sem (Output o ': r) a -> Sem r ([o], a)
#

Run an Output effect by transforming it into a list of its values, lazily.

Warning: This inherits the nasty space leak issue of WriterT! Don't use this if you don't have to.

valuerunLazyOutputMonoid
  1. :: Monoid m
  2. => o -> m
  3. -> Sem (Output o ': r) a
  4. -> Sem r (m, a)
#

Run an Output effect by transforming it into a monoid, and accumulate it lazily.

Warning: This inherits the nasty space leak issue of WriterT! Don't use this if you don't have to.

valueoutputToIOMonoid
  1. :: (Monoid m, Member (Embed IO) r)
  2. => o -> m
  3. -> Sem (Output o ': r) a
  4. -> Sem r (m, a)
#

Run an Output effect in terms of atomic operations in IO.

Internally, this simply creates a new IORef, passes it to runOutputMonoidIORef, and then returns the result and the final value of the IORef.

Beware: As this uses an IORef internally, all other effects will have local state semantics in regards to Output effects interpreted this way. For example, throw and catch will never revert outputs, even if runError is used after outputToIOMonoid.

valueoutputToIOMonoidAssocR
  1. :: (Monoid m, Member (Embed IO) r)
  2. => o -> m
  3. -> Sem (Output o ': r) a
  4. -> Sem r (m, a)
#

Like outputToIOMonoid, 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 outputToIOMonoid if the monoid is a list, such as String.

Beware: As this uses an IORef internally, all other effects will have local state semantics in regards to Output effects interpreted this way. For example, throw and catch will never revert outputs, even if runError is used after outputToIOMonoidAssocR.