Copyright  (C) 2012 Edward Kmett 

License  BSDstyle (see the file LICENSE) 
Maintainer  Edward Kmett <ekmett@gmail.com> 
Stability  provisional 
Portability  rank2, GADTs 
Safe Haskell  None 
Language  Haskell2010 
Synopsis
 newtype MachineT m k o = MachineT {
 runMachineT :: m (Step k o (MachineT m k o))
 data Step k o r
 type Machine k o = forall m. Monad m => MachineT m k o
 runT_ :: Monad m => MachineT m k b > m ()
 runT :: Monad m => MachineT m k b > m [b]
 run :: MachineT Identity k b > [b]
 runMachine :: MachineT Identity k o > Step k o (MachineT Identity k o)
 encased :: Monad m => Step k o (MachineT m k o) > MachineT m k o
 construct :: Monad m => PlanT k o m a > MachineT m k o
 repeatedly :: Monad m => PlanT k o m a > MachineT m k o
 unfoldPlan :: Monad m => s > (s > PlanT k o m s) > MachineT m k o
 before :: Monad m => MachineT m k o > PlanT k o m a > MachineT m k o
 preplan :: Monad m => PlanT k o m (MachineT m k o) > MachineT m k o
 deconstruct :: Monad m => MachineT m k (Either a o) > PlanT k o m a
 tagDone :: Monad m => (o > Bool) > MachineT m k o > MachineT m k (Either o o)
 finishWith :: Monad m => (o > Maybe r) > MachineT m k o > MachineT m k (Either r o)
 fit :: Monad m => (forall a. k a > k' a) > MachineT m k o > MachineT m k' o
 fitM :: (Monad m, Monad m') => (forall a. m a > m' a) > MachineT m k o > MachineT m' k o
 pass :: k o > Machine k o
 starve :: Monad m => MachineT m k0 b > MachineT m k b > MachineT m k b
 stopped :: Machine k b
 stepMachine :: Monad m => MachineT m k o > (Step k o (MachineT m k o) > MachineT m k' o') > MachineT m k' o'
 class Appliance k where
Machines
newtype MachineT m k o Source #
A MachineT
reads from a number of inputs and may yield results before stopping
with monadic sideeffects.
MachineT  

Instances
Monad m => Functor (MachineT m k) Source #  
(Monad m, Appliance k) => Applicative (MachineT m k) Source #  
Defined in Data.Machine.Type  
m ~ Identity => Foldable (MachineT m k) Source #  This permits toList to be used on a Machine. 
Defined in Data.Machine.Type fold :: Monoid m0 => MachineT m k m0 > m0 # foldMap :: Monoid m0 => (a > m0) > MachineT m k a > m0 # foldr :: (a > b > b) > b > MachineT m k a > b # foldr' :: (a > b > b) > b > MachineT m k a > b # foldl :: (b > a > b) > b > MachineT m k a > b # foldl' :: (b > a > b) > b > MachineT m k a > b # foldr1 :: (a > a > a) > MachineT m k a > a # foldl1 :: (a > a > a) > MachineT m k a > a # toList :: MachineT m k a > [a] # null :: MachineT m k a > Bool # length :: MachineT m k a > Int # elem :: Eq a => a > MachineT m k a > Bool # maximum :: Ord a => MachineT m k a > a # minimum :: Ord a => MachineT m k a > a #  
Monad m => Pointed (MachineT m k) Source #  
Defined in Data.Machine.Type  
Monad m => Semigroup (MachineT m k o) Source #  
Monad m => Monoid (MachineT m k o) Source #  
runT_ :: Monad m => MachineT m k b > m () Source #
Stop feeding input into model, taking only the effects.
runT :: Monad m => MachineT m k b > m [b] Source #
Stop feeding input into model and extract an answer
Building machines from plans
repeatedly :: Monad m => PlanT k o m a > MachineT m k o Source #
Generates a model that runs a machine until it stops, then start it up again.
repeatedly
m =construct
(forever
m)
unfoldPlan :: Monad m => s > (s > PlanT k o m s) > MachineT m k o Source #
Unfold a stateful PlanT into a MachineT.
before :: Monad m => MachineT m k o > PlanT k o m a > MachineT m k o Source #
Evaluate a machine until it stops, and then yield answers according to the supplied model.
preplan :: Monad m => PlanT k o m (MachineT m k o) > MachineT m k o Source #
Incorporate a Plan
into the resulting machine.
Deconstructing machines back into plans
tagDone :: Monad m => (o > Bool) > MachineT m k o > MachineT m k (Either o o) Source #
Use a predicate to mark a yielded value as the terminal value of
this Machine
. This is useful in combination with deconstruct
to
combine Plan
s.
finishWith :: Monad m => (o > Maybe r) > MachineT m k o > MachineT m k (Either r o) Source #
Use a function to produce and mark a yielded value as the
terminal value of a Machine
. All yielded values for which the
given function returns Nothing
are yielded down the pipeline, but
the first value for which the function returns a Just
value will
be returned by a Plan
created via deconstruct
.
Reshaping machines
fitM :: (Monad m, Monad m') => (forall a. m a > m' a) > MachineT m k o > MachineT m' k o Source #
starve :: Monad m => MachineT m k0 b > MachineT m k b > MachineT m k b Source #
Run a machine with no input until it stops, then behave as another machine.
stepMachine :: Monad m => MachineT m k o > (Step k o (MachineT m k o) > MachineT m k' o') > MachineT m k' o' Source #
Transform a Machine
by looking at a single step of that machine.