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

Safe HaskellNone
LanguageHaskell2010

Control.Effect.Type.WriterPrim

Contents

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:

Constructors

WriterPrimTell :: w -> WriterPrim w m () 
WriterPrimListen :: m a -> WriterPrim w m (w, a) 
WriterPrimPass :: m (w -> w, a) -> WriterPrim w m a 
Instances
Monoid s => ThreadsEff ListT (WriterPrim s) Source # 
Instance details

Defined in Control.Monad.Trans.List.Church

Methods

threadEff :: Monad m => (forall x. WriterPrim s m x -> m x) -> WriterPrim s (ListT m) a -> ListT m a Source #

(Reifies s (ReifiedEffAlgebra (WriterPrim w) m), Monoid w, Monad m) => MonadWriter w (ViaAlg s (WriterPrim w) m) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

writer :: (a, w) -> ViaAlg s (WriterPrim w) m a #

tell :: w -> ViaAlg s (WriterPrim w) m () #

listen :: ViaAlg s (WriterPrim w) m a -> ViaAlg s (WriterPrim w) m (a, w) #

pass :: ViaAlg s (WriterPrim w) m (a, w -> w) -> ViaAlg s (WriterPrim w) m a #

Monoid threadedMonoid => ThreadsEff (ExceptT e) (WriterPrim threadedMonoid) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

threadEff :: Monad m => (forall x. WriterPrim threadedMonoid m x -> m x) -> WriterPrim threadedMonoid (ExceptT e m) a -> ExceptT e m a Source #

Monoid s => ThreadsEff (WriterT s) (WriterPrim w) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

threadEff :: Monad m => (forall x. WriterPrim w m x -> m x) -> WriterPrim w (WriterT s m) a -> WriterT s m a Source #

Monoid threadedMonoid => ThreadsEff (StateT s) (WriterPrim threadedMonoid) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

threadEff :: Monad m => (forall x. WriterPrim threadedMonoid m x -> m x) -> WriterPrim threadedMonoid (StateT s m) a -> StateT s m a Source #

Monoid threadedMonoid => ThreadsEff (ReaderT i) (WriterPrim threadedMonoid) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

threadEff :: Monad m => (forall x. WriterPrim threadedMonoid m x -> m x) -> WriterPrim threadedMonoid (ReaderT i m) a -> ReaderT i m a Source #

Monoid threadedMonoid => ThreadsEff (StateT s) (WriterPrim threadedMonoid) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

threadEff :: Monad m => (forall x. WriterPrim threadedMonoid m x -> m x) -> WriterPrim threadedMonoid (StateT s m) a -> StateT s m a Source #

Monoid s => ThreadsEff (WriterT s) (WriterPrim w) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

threadEff :: Monad m => (forall x. WriterPrim w m x -> m x) -> WriterPrim w (WriterT s m) a -> WriterT s m a Source #

Monoid s => ThreadsEff (WriterT s) (WriterPrim w) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

threadEff :: Monad m => (forall x. WriterPrim w m x -> m x) -> WriterPrim w (WriterT s m) a -> WriterT s m a Source #

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 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.