chp-1.0.1: An implementation of concurrency ideas from Communicating Sequential Processes



A collection of useful functions to use with the library.



wireCycle :: Channel r w => [r a -> w a -> proc] -> CHP [proc]Source

Wires given processes up in a forward cycle. That is, the first process writes to the second, and receives from the last. It returns the list of wired-up processes, which you will almost certainly want to run in parallel.

wirePipeline :: forall a r w proc. Channel r w => [r a -> w a -> proc] -> r a -> w a -> CHP [proc]Source

Wires the given processes up in a forward pipeline. The first process in the list is connected to the given reading channel-end (the first parameter) and the writing end of a new channel, A. The second process is wired up to the reading end of A, and the writing end of the next new channel, B. This proceeds all the way to the end of the list, until the final process is wired to the reading end of Z (if you have 27 processes in the list, and therefore 26 channels in the middle of them) and the second parameter. The list of wired-up processes is returned, which you can then run in parallel.

(|->|) :: Channel r w => (a -> w b -> CHP ()) -> (r b -> c -> CHP ()) -> a -> c -> CHP ()Source

Process composition. Given two processes, composes them into a pipeline, like function composition (but with an opposite ordering). The function is associative. Using wirePipeline will be more efficient than foldl1 (|->|) for more than two processes.

(|<-|) :: Channel r w => (r b -> c -> CHP ()) -> (a -> w b -> CHP ()) -> a -> c -> CHP ()Source

The reversed version of the other operator.