Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data WriterPrim w m a where
- WriterPrimTell :: w -> WriterPrim w m ()
- WriterPrimListen :: m a -> WriterPrim w m (w, a)
- WriterPrimPass :: m (w -> w, a) -> WriterPrim w m a
- threadWriterPrim :: forall w t m a. (MonadTrans t, ThreadsEff t (ListenPrim w), Monad m) => ((forall x. WriterPrim w m x -> m x) -> t m (w -> w, a) -> t m a) -> (forall x. WriterPrim w m x -> m x) -> WriterPrim w (t m) a -> t m a
- threadWriterPrimViaClass :: forall w t m a. (Monoid w, MonadTrans t, Monad m) => (RepresentationalT t, forall b. MonadWriter w b => MonadWriter w (t b)) => (forall x. WriterPrim w m x -> m x) -> WriterPrim w (t m) a -> t m a
- algListenPrimIntoWriterPrim :: Algebra' (ListenPrim w ': p) m a -> (m (w -> w, a) -> m a) -> Algebra' (WriterPrim w ': p) m a
Effects
data WriterPrim w m a where Source #
A primitive effect that may be used for
interpreters of connected Tell
,
Listen
, and Pass
effects.
This combines Tell
and
Listen
and Pass
.
This may be relevant if there are monad transformers that may only lift
pass
if they also have access to
listen
and tell
.
WriterPrim
is only used as a primitive effect.
If you define a Carrier
that relies on a novel
non-trivial monad transformer t
, then you need to make
a
instance (if possible).
Monoid
w => ThreadsEff
t (WriterPrim
w)threadWriterPrim
and threadWriterPrimViaClass
can help you with that.
The following threading constraints accept WriterPrim
:
WriterPrimTell :: w -> WriterPrim w m () | |
WriterPrimListen :: m a -> WriterPrim w m (w, a) | |
WriterPrimPass :: m (w -> w, a) -> WriterPrim w m a |
Instances
Threading utilities
threadWriterPrim :: forall w t m a. (MonadTrans t, ThreadsEff t (ListenPrim w), Monad m) => ((forall x. WriterPrim w m x -> m x) -> t m (w -> w, a) -> t m a) -> (forall x. WriterPrim w m x -> m x) -> WriterPrim w (t m) a -> t m a Source #
Construct a valid definition of threadEff
for a
instance only be specifying how
ThreadsEff
t (WriterPrim
w)WriterPrimPass
should be lifted.
This relies on an existing
instance.ThreadsEff
t (ListenPrim
w)
threadWriterPrimViaClass :: forall w t m a. (Monoid w, MonadTrans t, Monad m) => (RepresentationalT t, forall b. MonadWriter w b => MonadWriter w (t b)) => (forall x. WriterPrim w m x -> m x) -> WriterPrim w (t m) a -> t m a Source #
A valid definition of threadEff
for a
instance,
given that Monoid
w => ThreadsEff
(WriterPrim
w) tt
lifts
.MonadWriter
w
Combinators for Algebra
s
algListenPrimIntoWriterPrim :: Algebra' (ListenPrim w ': p) m a -> (m (w -> w, a) -> m a) -> Algebra' (WriterPrim w ': p) m a Source #
Rewrite an Algebra
where the topmost effect is ListenPrim
into
an Algebra
where the topmost effect is WriterPrim
by providing
an implementation of WriterPrimPass
.