Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ListenPrim w m a where
- ListenPrimTell :: w -> ListenPrim w m ()
- ListenPrimListen :: m a -> ListenPrim w m (w, a)
- threadListenPrim :: forall w t m a. (MonadTrans t, Monad m) => (forall x. (forall y. ListenPrim w m y -> m y) -> t m x -> t m (w, x)) -> (forall x. ListenPrim w m x -> m x) -> ListenPrim w (t m) a -> t m a
- threadListenPrimViaClass :: forall w t m a. (Monoid w, Monad m) => (RepresentationalT t, MonadTrans t, forall b. MonadWriter w b => MonadWriter w (t b)) => (forall x. ListenPrim w m x -> m x) -> ListenPrim w (t m) a -> t m a
Effects
data ListenPrim w m a where Source #
A primitive effect that may be used for
interpreters of connected Tell
and
Listen
effects.
This combines Tell
and
Listen
. This may be relevant if there
are monad transformers that may only lift
listen
if they also have access to
tell
.
ListenPrim
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 (ListenPrim
w)threadListenPrim
and threadListenPrimViaClass
can help you with that.
The following threading constraints accept ListenPrim
:
ListenPrimTell :: w -> ListenPrim w m () | |
ListenPrimListen :: m a -> ListenPrim w m (w, a) |
Instances
Threading utilities
threadListenPrim :: forall w t m a. (MonadTrans t, Monad m) => (forall x. (forall y. ListenPrim w m y -> m y) -> t m x -> t m (w, x)) -> (forall x. ListenPrim w m x -> m x) -> ListenPrim w (t m) a -> t m a Source #
Construct a valid definition of threadEff
for a
instance
only be specifying how ThreadsEff
t (ListenPrim
w)ListenPrimListen
should be lifted.
This uses lift
to lift ListenPrimTell
.
threadListenPrimViaClass :: forall w t m a. (Monoid w, Monad m) => (RepresentationalT t, MonadTrans t, forall b. MonadWriter w b => MonadWriter w (t b)) => (forall x. ListenPrim w m x -> m x) -> ListenPrim w (t m) a -> t m a Source #
A valid definition of threadEff
for a
instance, given that ThreadsEff
t (ListenPrim
w)t
lifts
.MonadWriter
w
BEWARE: threadListenPrimViaClass
is only safe if the implementation of
listen
for t m
only makes use of listen
and tell
for m
, and not
pass
.