Portability | rank-2, GADTs |
---|---|
Stability | provisional |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Safe-Inferred |
- 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
- before :: Monad m => MachineT m k o -> PlanT k o m a -> 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
- stopped :: Machine k b
- class Appliance k where
Machines
A MachineT
reads from a number of inputs and may yield results before stopping
with monadic side-effects.
MachineT | |
|
runT_ :: Monad m => MachineT m k b -> m ()Source
Stop feeding input into model, taking only the effects.
Building machines from plans
repeatedly :: Monad m => PlanT k o m a -> MachineT m k oSource
Generates a model that runs a machine until it stops, then start it up again.
repeatedly
m =construct
(forever
m)
before :: Monad m => MachineT m k o -> PlanT k o m a -> MachineT m k oSource
Evaluate a machine until it stops, and then yield answers according to the supplied model.
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
.