
I just watched http://video.google.com/videoplay?docid=810232012617965344 It's a great talk that is suprisingly relevant to Haskell programming (although at first blush it looks a bit unrelated). (It refs a lot of older work that actually led me to Haskell in the first place by way of McIlroy's haskell power-series paper). Anyway, I thought it would be of general interest. A lot of the progrms he discusses are a lot more elegant in pure Haskell code (ie. prime number sieve, power series), but his language also supports an interesting imperative primitive that lets you pick the first available value from a set of channels which isn't available in pure Haskell expressions. Has anyone implemented a primitive like this for Haskell? Tim Newsham http://www.thenewsh.com/~newsham/

Tim Newsham
his language also supports an interesting imperative primitive that lets you pick the first available value from a set of channels which isn't available in pure Haskell expressions. Has anyone implemented a primitive like this for Haskell?
Could it be the "amb" described at http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice/ http://conal.net/blog/posts/smarter-termination-for-thread-racing/ ? -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig We want our revolution, and we want it now! -- Marat/Sade We want our revolution, and we'll take it at such time as you've gotten around to delivering it -- Haskell programmer

Tim Newsham
wrote in article in gmane.comp.lang.haskell.cafe: his language also supports an interesting imperative primitive that lets you pick the first available value from a set of channels which isn't available in pure Haskell expressions. Has anyone implemented a primitive like this for Haskell?
Could it be the "amb" described at http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice/ http://conal.net/blog/posts/smarter-termination-for-thread-racing/ ?
It reminds me a little of unamb but is different. Unamb is pure and picks the first computed value of several consistent computations. The select operator picks the first available value from a set of diff channels, some of which may have diff types and so is definitely not pure. Tim Newsham http://www.thenewsh.com/~newsham/

Tim Newsham
Could it be the "amb" described at http://conal.net/blog/posts/functional-concurrency-with-unambiguous-choice/ http://conal.net/blog/posts/smarter-termination-for-thread-racing/ ? It reminds me a little of unamb but is different.
I agree, but could it be the "amb" described there? -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig We want our revolution, and we want it now! -- Marat/Sade We want our revolution, and we'll take it at such time as you've gotten around to delivering it -- Haskell programmer

On Fri, Jun 5, 2009 at 8:14 PM, Tim Newsham
I just watched http://video.google.com/videoplay?docid=810232012617965344
It's a great talk that is suprisingly relevant to Haskell programming (although at first blush it looks a bit unrelated). (It refs a lot of older work that actually led me to Haskell in the first place by way of McIlroy's haskell power-series paper). Anyway, I thought it would be of general interest.
A lot of the progrms he discusses are a lot more elegant in pure Haskell code (ie. prime number sieve, power series), but his language also supports an interesting imperative primitive that lets you pick the first available value from a set of channels which isn't available in pure Haskell expressions. Has anyone implemented a primitive like this for Haskell?
Traditionally and as demonstrated in McIlroy's power series paper, channels are modelled as streams. I'm pretty sure the primitive you are looking for is (equivalent to) the non-deterministic merge, which is, again, the traditional way of adding such features (see, e.g. SICP). It is of course an impure operation and thus not implementable in pure Haskell and not a pure expression in Haskell. It is implemented in Control.Concurrent as mergeIO and nmergeIO. http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurren... And yes, Rob Pike's work is great. I particularly like the concurrent windowing system stuff and would like to implement something like it in (Concurrent) Haskell.

Tim Newsham
Has anyone implemented a primitive like this for Haskell?
This is the CSP external choice operator; it's often called "select" or
"alt" in CSP-inspired languages. Neil Brown's CHP library provides CSP
programming facilities in Haskell, including a <-> choice operator:
http://www.cs.kent.ac.uk/projects/ofa/chp/
--
Adam Sampson
participants (4)
-
Adam Sampson
-
Chung-chieh Shan
-
Derek Elkins
-
Tim Newsham