effectful-core-2.3.0.1: An easy to use, performant extensible effects library.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Effectful.Writer.Dynamic

Description

The dynamically dispatched variant of the Writer effect.

Note: unless you plan to change interpretations at runtime, it's recommended to use one of the statically dispatched variants, i.e. Effectful.Writer.Static.Local or Effectful.Writer.Static.Shared.

Synopsis

Effect

data Writer w :: Effect where Source #

Provide access to a write only value of type w.

Constructors

Tell :: w -> Writer w m () 
Listen :: m a -> Writer w m (a, w) 

Instances

Instances details
type DispatchOf (Writer w) Source # 
Instance details

Defined in Effectful.Writer.Dynamic

Handlers

Local

runWriterLocal :: Monoid w => Eff (Writer w ': es) a -> Eff es (a, w) Source #

Run the Writer effect and return the final value along with the final output (via Effectful.Writer.Static.Local).

execWriterLocal :: Monoid w => Eff (Writer w ': es) a -> Eff es w Source #

Run a Writer effect and return the final output, discarding the final value (via Effectful.Writer.Static.Local).

Shared

runWriterShared :: Monoid w => Eff (Writer w ': es) a -> Eff es (a, w) Source #

Run the Writer effect and return the final value along with the final output (via Effectful.Writer.Static.Shared).

execWriterShared :: Monoid w => Eff (Writer w ': es) a -> Eff es w Source #

Run the Writer effect and return the final output, discarding the final value (via Effectful.Writer.Static.Shared).

Operations

tell :: (HasCallStack, Writer w :> es) => w -> Eff es () Source #

Append the given output to the overall output of the Writer.

listen :: (HasCallStack, Writer w :> es) => Eff es a -> Eff es (a, w) Source #

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

listens :: (HasCallStack, Writer w :> es) => (w -> b) -> Eff es a -> Eff es (a, b) Source #

Execute an action and append its output to the overall output of the Writer, then return the final value along with a function of the recorded output.

listens f m ≡ second f <$> listen m