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



Contains a process for easily using stdin, stdout and stderr as channels.



data ConsoleChans Source

A set of channels to be given to the process to run, containing channels for stdin, stdout and stderr.

consoleProcess :: (ConsoleChans -> CHP ()) -> CHP ()Source

A function for running the given CHP process that wants console channels. When your program finishes, the console channels are automatically poisoned, but it's good practice to poison them yourself when you finish. Only ever run one of these processes at a time, or undefined behaviour will result.

Note: getting the input handler to terminate is surpisingly difficult in Haskell. Currently it seems (version 6.8.2) that GHC compiling the end program with -threaded requires an extra character to be input before the input handler notices poison, whereas GHC compiled (not using -threaded) and GHCi act as intended. This is not a problem with the whole of the library, only with this consoleProcess. Unfortunately this means the one or two poison examples in the tutorial may not function correctly. I hope to resolve this problem in the next version.