polysemy-1.9.1.0: Higher-order, low-boilerplate free monads.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Polysemy.Internal.Writer

Description

 
Synopsis

Documentation

data Writer o m a where Source #

An effect capable of emitting and intercepting messages.

Constructors

Tell :: o -> Writer o m ()

Write a message to the log.

Listen :: forall o m a. m a -> Writer o m (o, 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.

pass :: forall o r a. Member (Writer o) r => Sem r (o -> o, a) -> Sem r a Source #

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

listen :: forall o r a. Member (Writer o) r => Sem r a -> Sem r (o, a) Source #

Return the log produced by the higher-order action.

tell :: forall o r. Member (Writer o) r => o -> Sem r () Source #

Write a message to the log.

writerToEndoWriter :: (Monoid o, Member (Writer (Endo o)) r) => Sem (Writer o ': r) a -> Sem r a Source #

Transform a Writer o effect into a Writer (Endo o) effect, right-associating all uses of <> for o.

This can be used together with raiseUnder in order to create -AssocR variants out of regular Writer interpreters.

Since: 1.2.0.0

runWriterSTMAction :: forall o r a. (Member (Final IO) r, Monoid o) => (o -> STM ()) -> Sem (Writer o ': r) a -> Sem r a Source #

A variant of runWriterTVar where an STM action is used instead of a TVar to commit tells.