free-operational-0.5.0.0: Operational Applicative, Alternative, Monad and MonadPlus from free types.

Safe HaskellNone

Control.Monad.Trans.Operational

Synopsis

Documentation

newtype ProgramT instr m a Source

Constructors

ProgramT 

Fields

toFreeT :: FreeT (Coyoneda instr) m a
 

Instances

Monad m => Operational instr (ProgramT instr m) 
MonadTrans (ProgramT instr) 
Monad m => Monad (ProgramT instr m) 
Monad m => Functor (ProgramT instr m) 
Monad m => Applicative (ProgramT instr m) 

interpretTSource

Arguments

:: forall t m instr a . (MonadTrans t, Functor (t m), Monad (t m), Functor m, Monad m) 
=> (forall n x. (Functor n, Monad n) => instr x -> t n x)

interpret instr over a transformer t and any wrapped monad n.

-> ProgramT instr m a 
-> t m a 

Given an intepretation of instr x as actions over a given monad transformer t (transforming over an arbitrary monad m), interpret ProgramT instr as a monad transformer t. Read that sentence and the type carefully: the instruction interpretation can pick its choice of t but not m.

interpretTMSource

Arguments

:: (MonadTrans t, Functor (t m), Monad (t m), Monad m) 
=> (forall x. instr x -> t m x)

interpret instr over t m

-> ProgramT instr m a 
-> t m a 

Given an intepretation of instr x as actions over a given transformed monad t m, interpret ProgramT instr as a transformed monad t m. Read that sentence and the type carefully: the instruction interpretation can pick its choice of both t and m.

interpretM :: (Functor m, Monad m) => (forall x. instr x -> m x) -> ProgramT instr m a -> m aSource

data ProgramViewT instr m a whereSource

Constructors

Return :: a -> ProgramViewT instr m a 
:>>= :: instr a -> (a -> ProgramT instr m b) -> ProgramViewT instr m b 

viewT :: Monad m => ProgramT instr m a -> m (ProgramViewT instr m a)Source