Safe Haskell | None |
---|---|

Language | Haskell2010 |

Routing for splitting and merging processing pipelines.

## Synopsis

- scatter :: MonadBaseControl IO m => [MachineT m k o] -> MachineT m k o
- mergeSum :: forall m a b r. MonadBaseControl IO m => ProcessT m a r -> ProcessT m b r -> ProcessT m (Either a b) r
- splitSum :: forall m a b c d. MonadBaseControl IO m => ProcessT m a b -> ProcessT m c d -> ProcessT m (Either a c) (Either b d)
- splitProd :: forall m a b r. MonadBaseControl IO m => ProcessT m a r -> ProcessT m b r -> ProcessT m (a, b) r

# Documentation

scatter :: MonadBaseControl IO m => [MachineT m k o] -> MachineT m k o Source #

Produces values from whichever source `MachineT`

yields
first. This operation may also be viewed as a *gather* operation in
that all values produced by the given machines are interleaved when
fed downstream. Note that inputs are *not* shared. The composite
machine will await an input when any constituent machine awaits an
input. That input will be supplied to the awaiting constituent and
no other.

Some examples of more specific useful types `scatter`

may be used
at,

scatter :: [ProcessT m a b] -> ProcessT m a b scatter :: [SourceT m a] -> SourceT m a

The former may be used to stream data through a collection of
worker `Process`

es, the latter may be used to intersperse values
from a collection of sources.

mergeSum :: forall m a b r. MonadBaseControl IO m => ProcessT m a r -> ProcessT m b r -> ProcessT m (Either a b) r Source #

Similar to `|||`

: split the input between two
processes and merge their outputs.

Connect two processes to the downstream tails of a `Machine`

that
produces `Either`

s. The two downstream consumers are run
concurrently when possible. When one downstream consumer stops, the
other is allowed to run until it stops or the upstream source
yields a value the remaining consumer can not handle.

`mergeSum sinkL sinkR`

produces a topology like this,

sinkL / \ a \ / \ source -- Either a b --> -- r --> \ / b / \ / sinkR

splitSum :: forall m a b c d. MonadBaseControl IO m => ProcessT m a b -> ProcessT m c d -> ProcessT m (Either a c) (Either b d) Source #

Similar to `+++`

: split the input between two
processes, retagging and merging their outputs.

The two processes are run concurrently whenever possible.

splitProd :: forall m a b r. MonadBaseControl IO m => ProcessT m a r -> ProcessT m b r -> ProcessT m (a, b) r Source #

Connect two processes to the downstream tails of a `Machine`

that
produces tuples. The two downstream consumers are run
concurrently. When one downstream consumer stops, the entire
pipeline is stopped.

`splitProd sink1 sink2`

produces a topology like this,

sink1 / \ a \ / \ source -- (a,b) --> -- r --> \ / b / \ / sink2