chp-1.3.0: An implementation of concurrency ideas from Communicating Sequential ProcessesSource codeContentsIndex
Control.Concurrent.CHP.Utils
Description
A collection of useful functions to use with the library.
Synopsis
wireCycle :: Channel r w => [r a -> w a -> proc] -> CHP [proc]
wirePipeline :: forall a r w proc. Channel r w => [r a -> w a -> proc] -> r a -> w a -> CHP [proc]
pipeline :: [Chanin a -> Chanout a -> CHP b] -> Chanin a -> Chanout a -> CHP [b]
cycle :: [Chanin a -> Chanout a -> CHP b] -> CHP [b]
(|->|) :: (a -> Chanout b -> CHP ()) -> (Chanin b -> c -> CHP ()) -> a -> c -> CHP ()
(|<-|) :: (Chanin b -> c -> CHP ()) -> (a -> Chanout b -> CHP ()) -> a -> c -> CHP ()
(->|) :: (Chanout b -> CHP ()) -> (Chanin b -> c -> CHP ()) -> c -> CHP ()
(|->) :: (a -> Chanout b -> CHP ()) -> (Chanin b -> CHP ()) -> a -> CHP ()
Documentation
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.
pipeline :: [Chanin a -> Chanout a -> CHP b] -> Chanin a -> Chanout a -> CHP [b]Source

A specialised version of wirePipeline. Given a list of processes, composes them into an ordered pipeline, that takes the channel-ends for the sticking out ends of the pipeline and gives a process that returns a list of their results. This is equivalent to wirePipeline, with the return value fed to runParallel.

Added in version 1.0.2.

cycle :: [Chanin a -> Chanout a -> CHP b] -> CHP [b]Source

A specialised version of wireCycle. Given a list of processes, composes them into a cycle and runs them all in parallel. This is equivalent to wireCycle with the return value fed into runParallel.

Added in version 1.0.2.

(|->|) :: (a -> Chanout b -> CHP ()) -> (Chanin 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.

The type for this process became more specific in version 1.2.0.

(|<-|) :: (Chanin b -> c -> CHP ()) -> (a -> Chanout b -> CHP ()) -> a -> c -> CHP ()Source

The reversed version of the other operator.

The type for this process became more specific in version 1.2.0.

(->|) :: (Chanout b -> CHP ()) -> (Chanin b -> c -> CHP ()) -> c -> CHP ()Source
A function to use at the start of a pipeline you are chaining together with the '(|->|)' operator. Added in version 1.2.0.
(|->) :: (a -> Chanout b -> CHP ()) -> (Chanin b -> CHP ()) -> a -> CHP ()Source
A function to use at the end of a pipeline you are chaining together with the '(|->|)' operator. Added in version 1.2.0.
Produced by Haddock version 2.4.2