Provides an instance of Arrow for process pipelines. As described in the original paper on arrows, they can be used to represent stream processing, so CHP seemed like a possible fit for an arrow.
Whether this is actually an instance of Arrow depends on technicalities. This can be demonstrated with the arrow law arr id >>> f = f = f >>> arr id. Whether CHP satisfies this arrow law depends on the definition of equality.
The problem lies in the buffering inherent in arrows. Imagine if f is a single function. f is effectively a buffer of one. You can feed it a single value, but no more than that until you read its output. However, if you have arr id >>> f, that can accept two inputs (one held by the arr id process and one held by f) before you must accept the output.
I am fairly confident that the arrow laws are satisfied for the definition of equality that given the same single input, they will produce the same single output. If you don't worry too much about the behavioural difference, and just take arrows as another way to wire together a certain class of process network, you should do fine.
All your processes should produce exactly one output per input, or else you will find odd behaviour resulting.
Added in version 1.0.2.
The pipeline will run forever (until poisoned) and you must run it in parallel to whatever is feeding it the inputs and reading off the outputs. Imagine that you want a process pipeline that takes in a pair of numbers, doubles the first and adds one to the second. You could encode this in an arrow using:
runPipeline (arr (*2) *** arr (+1))
Arrows are more useful where you already have processes written that process data and you want to easily wire them together. The arrow notation is probably easier for doing that than declaring all the channels yourself and composing everything in parallel.
|Produced by Haddock version 2.3.0|