in-other-words-0.1.0.0: A higher-order effect system where the sky's the limit

Control.Effect.Type.WriterPrim

Synopsis

# 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 Monoid w => ThreadsEff t (WriterPrim w) instance (if possible). threadWriterPrim and threadWriterPrimViaClass can help you with that.

The following threading constraints accept WriterPrim:

• ReaderThreads
• StateThreads
• StateLazyThreads
• ErrorThreads
• WriterThreads
• WriterLazyThreads
• NonDetThreads

Constructors

 WriterPrimTell :: w -> WriterPrim w m () WriterPrimListen :: m a -> WriterPrim w m (w, a) WriterPrimPass :: m (w -> w, a) -> WriterPrim w m a

#### Instances

Instances details

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 ThreadsEff t (WriterPrim w) instance only be specifying how WriterPrimPass should be lifted.

This relies on an existing ThreadsEff t (ListenPrim w) instance.

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 Monoid w => ThreadsEff (WriterPrim w) t instance, given that t lifts MonadWriter w.

# Combinators for Algebras

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.