Communicating Haskell Processes: The Long And The Short Of It
It’s been a long time coming, but I have completed the final corrected version of my PhD thesis. It’s entitled, rather unimaginatively (and against received wisdom), “Communicating Haskell Processes”. (Communicating Haskell Processes, or CHP for short, is my concurrent message-passing library for Haskell.) A lot of what’s in there has been on this blog before. The new bits are the slightly revised CHP design (which will be in the forthcoming 3.0.0 release) and operational semantics in chapter 3. It’s freely available online for you to read, all 250+ pages.
Meanwhile, I’ve also put together a condensed version of the new material — including mobile (suspendable) processes, and automatic poison, neither of which I’ve written about anywhere else — into a paper for the Haskell symposium, which is a more palatable 12 pages. I’m not going to copy out the whole paper into this post, but here’s a quick summary of automatic poison.
Poison is a way to shut down a process network: processes should catch poison (which can occur if a channel you are using becomes poisoned) and poison all their own channels, spreading the poison throughout the network until all of the processes have shut down. The standard idiom is to surround your whole code with an onPoisonRethrow block that poisons the channels:
deltaOrig :: Chanin a -> [Chanout a] -> CHP () deltaOrig input outputs = (forever $ do x <- readChannel input parallel_ [writeChannel c x | c <- outputs] ) `onPoisonRethrow` (poison input >> mapM_ poison outputs)
Automatic poison puts all this poison handling into an autoPoison function that wraps your process with the poison handling, so for the above we can substitute this instead:
deltaAuto, deltaAuto' :: Chanin a -> [Chanout a] -> CHP () deltaAuto = autoPoison deltaAuto' deltaAuto' input outputs = forever $ do x <- readChannel input parallel_ [writeChannel c x | c <- outputs]
I haven’t saved masses of code there, but I think the latter version is more readable. Read the paper for more details.
Comments are welcome on the paper, which is due on Monday (6th June). Comments are slightly less welcome on the thesis, because it’s already been sent for binding! If there is a mistake, I’m happy to correct it in the online version.