Copyright | (C) 2012 Edward Kmett Rúnar Bjarnason |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | Rank-N Types, MPTCs |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- type Plan k o a = forall m. PlanT k o m a
- runPlan :: PlanT k o Identity a -> (a -> r) -> (o -> r -> r) -> (forall z. (z -> r) -> k z -> r -> r) -> r -> r
- newtype PlanT k o m a = PlanT {
- runPlanT :: forall r. (a -> m r) -> (o -> m r -> m r) -> (forall z. (z -> m r) -> k z -> m r -> m r) -> m r -> m r
- yield :: o -> Plan k o ()
- maybeYield :: Maybe o -> Plan k o ()
- await :: Category k => Plan (k i) o i
- stop :: Plan k o a
- awaits :: k i -> Plan k o i
- exhaust :: Monad m => m (Maybe a) -> PlanT k a m ()
Plans
type Plan k o a = forall m. PlanT k o m a Source #
A
is a specification for a pure Plan
k o aMachine
, that reads inputs selected by k
with types based on i
, writes values of type o
, and has intermediate results of type a
.
A
can be used as a Plan
k o a
for any PlanT
k o m a
.Monad
m
It is perhaps easier to think of Plan
in its un-cps'ed form, which would
look like:
data Plan
k o a
= Done a
| Yield o (Plan k o a)
| forall z. Await (z -> Plan k o a) (k z) (Plan k o a)
| Fail
runPlan :: PlanT k o Identity a -> (a -> r) -> (o -> r -> r) -> (forall z. (z -> r) -> k z -> r -> r) -> r -> r Source #
newtype PlanT k o m a Source #
PlanT | |
|
Instances
MonadReader e m => MonadReader e (PlanT k o m) Source # | |
MonadState s m => MonadState s (PlanT k o m) Source # | |
MonadWriter w m => MonadWriter w (PlanT k o m) Source # | |
MonadError e m => MonadError e (PlanT k o m) Source # | |
Defined in Data.Machine.Plan throwError :: e -> PlanT k o m a # catchError :: PlanT k o m a -> (e -> PlanT k o m a) -> PlanT k o m a # | |
MonadTrans (PlanT k o) Source # | |
Defined in Data.Machine.Plan | |
Monad (PlanT k o m) Source # | |
Functor (PlanT k o m) Source # | |
MonadFail (PlanT k o m) Source # | |
Defined in Data.Machine.Plan | |
Applicative (PlanT k o m) Source # | |
Defined in Data.Machine.Plan | |
MonadIO m => MonadIO (PlanT k o m) Source # | |
Defined in Data.Machine.Plan | |
Alternative (PlanT k o m) Source # | |
MonadPlus (PlanT k o m) Source # | |
maybeYield :: Maybe o -> Plan k o () Source #
Like yield, except stops if there is no value to yield.