in-other-words-0.1.1.0: A higher-order effect system where the sky's the limit
Safe HaskellNone
LanguageHaskell2010

Control.Effect.Type.WriterPrim

Synopsis

Effects

data WriterPrim o :: Effect 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 o => ThreadsEff t (WriterPrim o) instance (if possible). threadWriterPrim and threadWriterPrimViaClass can help you with that.

The following threading constraints accept WriterPrim:

Constructors

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

Instances

Instances details
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 o) m), Monoid o, Monad m) => MonadWriter o (ViaAlg s (WriterPrim o) m) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

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

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

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

pass :: ViaAlg s (WriterPrim o) m (a, o -> o) -> ViaAlg s (WriterPrim o) 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 o) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

threadEff :: Monad m => (forall x. WriterPrim o m x -> m x) -> WriterPrim o (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 o) Source # 
Instance details

Defined in Control.Effect.Type.WriterPrim

Methods

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

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

Defined in Control.Effect.Type.WriterPrim

Methods

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

Threading utilities

threadWriterPrim :: forall o t m a. (MonadTrans t, ThreadsEff t (ListenPrim o), Monad m) => ((forall x. WriterPrim o m x -> m x) -> t m (o -> o, a) -> t m a) -> (forall x. WriterPrim o m x -> m x) -> WriterPrim o (t m) a -> t m a Source #

Construct a valid definition of threadEff for a ThreadsEff t (WriterPrim o) instance only be specifying how WriterPrimPass should be lifted.

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

threadWriterPrimViaClass :: forall o t m a. (Monoid o, MonadTrans t, Monad m) => (RepresentationalT t, forall b. MonadWriter o b => MonadWriter o (t b)) => (forall x. WriterPrim o m x -> m x) -> WriterPrim o (t m) a -> t m a Source #

A valid definition of threadEff for a Monoid o => ThreadsEff (WriterPrim o) t instance, given that t lifts MonadWriter w.

Combinators for Algebras

algListenPrimIntoWriterPrim :: Algebra' (ListenPrim o ': p) m a -> (m (o -> o, a) -> m a) -> Algebra' (WriterPrim o ': 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.