Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data ListenPrim o :: Effect where
- ListenPrimTell :: o -> ListenPrim o m ()
- ListenPrimListen :: m a -> ListenPrim o m (o, a)
- threadListenPrim :: forall o t m a. (MonadTrans t, Monad m) => (forall x. (forall y. ListenPrim o m y -> m y) -> t m x -> t m (o, x)) -> (forall x. ListenPrim o m x -> m x) -> ListenPrim o (t m) a -> t m a
- threadListenPrimViaClass :: forall o t m a. (Monoid o, Monad m) => (RepresentationalT t, MonadTrans t, forall b. MonadWriter o b => MonadWriter o (t b)) => (forall x. ListenPrim o m x -> m x) -> ListenPrim o (t m) a -> t m a
Effects
data ListenPrim o :: Effect 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
o => ThreadsEff
t (ListenPrim
o)threadListenPrim
and threadListenPrimViaClass
can help you with that.
The following threading constraints accept ListenPrim
:
ListenPrimTell :: o -> ListenPrim o m () | |
ListenPrimListen :: m a -> ListenPrim o m (o, a) |
Instances
Threading utilities
threadListenPrim :: forall o t m a. (MonadTrans t, Monad m) => (forall x. (forall y. ListenPrim o m y -> m y) -> t m x -> t m (o, x)) -> (forall x. ListenPrim o m x -> m x) -> ListenPrim o (t m) a -> t m a Source #
Construct a valid definition of threadEff
for a
instance
only be specifying how ThreadsEff
t (ListenPrim
o)ListenPrimListen
should be lifted.
This uses lift
to lift ListenPrimTell
.
threadListenPrimViaClass :: forall o t m a. (Monoid o, Monad m) => (RepresentationalT t, MonadTrans t, forall b. MonadWriter o b => MonadWriter o (t b)) => (forall x. ListenPrim o m x -> m x) -> ListenPrim o (t m) a -> t m a Source #
A valid definition of threadEff
for a
instance, given that ThreadsEff
t (ListenPrim
o)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
.