machines-0.1.2: Networked stream transducers

PortabilityRank-N Types, MPTCs
MaintainerEdward Kmett <>
Safe HaskellSafe-Inferred







type Plan k i o a = forall m. PlanT k i o m aSource

A Plan k i o a is a specification for a pure Machine, that reads inputs selected by k with types based on i, writes values of type o, and has intermediate results of type a.

A PlanT k i o a can be used as a PlanT k i o m a for any Monad m.

It is perhaps easier to think of Plan in its un-cps'ed form, which would look like:

 data Plan k i o a
   = Done a
   | Yield o (Plan k i o a)
   | forall z. Await (z -> Plan k i o a) (k i z) (Plan k i o a)
   | Fail

runPlan :: PlanT k i o Identity a -> (a -> r) -> (o -> r -> r) -> (forall z. (z -> r) -> k i z -> r -> r) -> r -> rSource

Deconstruct a Plan without reference to a Monad.

newtype PlanT k i o m a Source

You can construct a Plan (or PlanT), turning it into a Machine (or MachineT).




runPlanT :: forall r. (a -> m r) -> (o -> m r -> m r) -> (forall z. (z -> m r) -> k i z -> m r -> m r) -> m r -> m r


(Monad (PlanT k i o m), MonadError e m) => MonadError e (PlanT k i o m) 
(Monad (PlanT k i o m), MonadReader e m) => MonadReader e (PlanT k i o m) 
(Monad (PlanT k i o m), MonadState s m) => MonadState s (PlanT k i o m) 
MonadTrans (PlanT k i o) 
Monad (PlanT k i o m) 
Functor (PlanT k i o m) 
Monad (PlanT k i o m) => MonadPlus (PlanT k i o m) 
Functor (PlanT k i o m) => Applicative (PlanT k i o m) 
Applicative (PlanT k i o m) => Alternative (PlanT k i o m) 
(Monad (PlanT k i o m), MonadIO m) => MonadIO (PlanT k i o m) 

yield :: o -> Plan k i o ()Source

Output a result.

await :: Category k => Plan k i o iSource

Wait for input.

await = awaits id

awaits :: k i j -> Plan k i o jSource

Wait for a particular input.

 awaits L  :: Plan T (a, b) o a
 awaits R  :: Plan T (a, b) o b
 awaits id :: Plan Is i o i