Support for access to a write only value of a particular type.
The value is shared between multiple threads. If you want each thead to
manage its own version of the value, use Effectful.Writer.Static.Local.
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.
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!"