| Copyright | (C) 2012 Edward Kmett |
|---|---|
| License | BSD-style (see the file LICENSE) |
| Maintainer | Edward Kmett <ekmett@gmail.com> |
| Stability | provisional |
| Portability | rank-2, GADTs |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Data.Machine.Type
Contents
Description
- 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
- 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
A MachineT reads from a number of inputs and may yield results before stopping
with monadic side-effects.
Constructors
| MachineT | |
Fields
| |
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.
repeatedlym =construct(foreverm)
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.
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 Plans.
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
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.