| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Polysemy.Writer
Synopsis
- data Writer o m a where
- tell :: forall o r. MemberWithError (Writer o) r => o -> Sem r ()
- listen :: forall o r a. MemberWithError (Writer o) r => Sem r a -> Sem r (o, a)
- pass :: forall o r a. MemberWithError (Writer o) r => Sem r (o -> o, a) -> Sem r a
- censor :: Member (Writer o) r => (o -> o) -> Sem r a -> Sem r a
- runWriter :: Monoid o => Sem (Writer o ': r) a -> Sem r (o, a)
- runLazyWriter :: forall o r a. Monoid o => Sem (Writer o ': r) a -> Sem r (o, a)
- runWriterAssocR :: Monoid o => Sem (Writer o ': r) a -> Sem r (o, a)
- runLazyWriterAssocR :: Monoid o => Sem (Writer o ': r) a -> Sem r (o, a)
- runWriterTVar :: (Monoid o, Member (Final IO) r) => TVar o -> Sem (Writer o ': r) a -> Sem r a
- writerToIOFinal :: (Monoid o, Member (Final IO) r) => Sem (Writer o ': r) a -> Sem r (o, a)
- writerToIOAssocRFinal :: (Monoid o, Member (Final IO) r) => Sem (Writer o ': r) a -> Sem r (o, a)
- writerToEndoWriter :: (Monoid o, Member (Writer (Endo o)) r) => Sem (Writer o ': r) a -> Sem r a
- outputToWriter :: Member (Writer o) r => Sem (Output o ': r) a -> Sem r a
Effect
data Writer o m a where Source #
An effect capable of emitting and intercepting messages.
Constructors
| Tell :: o -> Writer o m () | |
| Listen :: forall o m a. m a -> Writer o m (o, a) | |
| Pass :: m (o -> o, a) -> Writer o m a | 
Instances
| type DefiningModule Writer Source # | |
| Defined in Polysemy.Internal.Writer | |
Actions
Interpretations
runLazyWriterAssocR :: Monoid o => Sem (Writer o ': r) a -> Sem r (o, a) Source #
Like runLazyWriter, 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 runLazyWriter if the monoid
 is a list, such as String.
Warning: This inherits the nasty space leak issue of
 WriterT! Don't use this if you don't have to.
Since: 1.3.0.0
runWriterTVar :: (Monoid o, Member (Final IO) r) => TVar o -> Sem (Writer o ': r) a -> Sem r a Source #
writerToIOFinal :: (Monoid o, Member (Final IO) r) => Sem (Writer o ': r) a -> Sem r (o, a) Source #
Run a Writer effect by transforming it into atomic operations
 through final IO.
Internally, this simply creates a new TVar, passes it to
 runWriterTVar, and then returns the result and the final value
 of the TVar.
Beware: Effects that aren't interpreted in terms of IO
 will have local state semantics in regards to Writer effects
 interpreted this way. See Final.
Since: 1.2.0.0
writerToIOAssocRFinal :: (Monoid o, Member (Final IO) r) => Sem (Writer o ': r) a -> Sem r (o, a) Source #
Like writerToIOFinal. 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 writerToIOFinal if the monoid
 is a list, such as String.
Beware: Effects that aren't interpreted in terms of IO
 will have local state semantics in regards to Writer effects
 interpreted this way. See Final.
Since: 1.2.0.0
writerToEndoWriter :: (Monoid o, Member (Writer (Endo o)) r) => Sem (Writer o ': r) a -> Sem r a Source #