Copyright | (C) 2012 Edward Kmett |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Stability | provisional |
Portability | Rank 2 Types, GADTs |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
- type Process a b = Machine (Is a) b
- type ProcessT m a b = MachineT m (Is a) b
- class Automaton k where
- process :: Monad m => (forall a. k a -> i -> a) -> MachineT m k o -> ProcessT m i o
- (<~) :: Monad m => ProcessT m b c -> MachineT m k b -> MachineT m k c
- (~>) :: Monad m => MachineT m k b -> ProcessT m b c -> MachineT m k c
- echo :: Process a a
- supply :: Monad m => [a] -> ProcessT m a b -> ProcessT m a b
- prepended :: Foldable f => f a -> Process a a
- filtered :: (a -> Bool) -> Process a a
- dropping :: Int -> Process a a
- taking :: Int -> Process a a
- droppingWhile :: (a -> Bool) -> Process a a
- takingWhile :: (a -> Bool) -> Process a a
- buffered :: Int -> Process a [a]
- fold :: Category k => (a -> b -> a) -> a -> Machine (k b) a
- fold1 :: Category k => (a -> a -> a) -> Machine (k a) a
- scan :: Category k => (a -> b -> a) -> a -> Machine (k b) a
- scan1 :: Category k => (a -> a -> a) -> Machine (k a) a
- scanMap :: (Category k, Monoid b) => (a -> b) -> Machine (k a) b
- asParts :: Foldable f => Process (f a) a
- sinkPart_ :: Monad m => (a -> (b, c)) -> ProcessT m c Void -> ProcessT m a b
- autoM :: Monad m => (a -> m b) -> ProcessT m a b
- final :: Category k => Machine (k a) a
- finalOr :: Category k => a -> Machine (k a) a
- intersperse :: Category k => a -> Machine (k a) a
- largest :: (Category k, Ord a) => Machine (k a) a
- smallest :: (Category k, Ord a) => Machine (k a) a
- sequencing :: (Category k, Monad m) => MachineT m (k (m a)) a
- mapping :: Category k => (a -> b) -> Machine (k a) b
- reading :: (Category k, Read a) => Machine (k String) a
- showing :: (Category k, Show a) => Machine (k a) String
Processes
type Process a b = Machine (Is a) b Source
A
is a stream transducer that can consume values of type Process
a ba
from its input, and produce values of type b
for its output.
Common Processes
filtered :: (a -> Bool) -> Process a a Source
A Process
that only passes through inputs that match a predicate.
taking :: Int -> Process a a Source
A Process
that passes through the first n
elements from its input then stops
droppingWhile :: (a -> Bool) -> Process a a Source
A Process
that drops elements while a predicate holds
takingWhile :: (a -> Bool) -> Process a a Source
A Process
that passes through elements until a predicate ceases to hold, then stops
buffered :: Int -> Process a [a] Source
Chunk up the input into n
element lists.
Avoids returning empty lists and deals with the truncation of the final group.
scanMap :: (Category k, Monoid b) => (a -> b) -> Machine (k a) b Source
Like scan
only uses supplied function to map and uses Monoid for
associative operation
asParts :: Foldable f => Process (f a) a Source
Break each input into pieces that are fed downstream individually.
sinkPart_ :: Monad m => (a -> (b, c)) -> ProcessT m c Void -> ProcessT m a b Source
sinkPart_ toParts sink
creates a process that uses the
toParts
function to break input into a tuple of (passAlong,
sinkPart)
for which the second projection is given to the supplied
sink
ProcessT
(that produces no output) while the first
projection is passed down the pipeline.
autoM :: Monad m => (a -> m b) -> ProcessT m a b Source
Apply a monadic function to each element of a ProcessT
.
intersperse :: Category k => a -> Machine (k a) a Source
Intersperse an element between the elements of the input
intersperse
:: a ->Process
a a
sequencing :: (Category k, Monad m) => MachineT m (k (m a)) a Source
Convert a stream of actions to a stream of values
mapping :: Category k => (a -> b) -> Machine (k a) b Source
Apply a function to all values coming from the input