Only suggestion would be to investigate using a different mechanism
for parallelism. Your program looks like it could use safer forms of
parallelism such as 'par' and 'pseq', parallel strategies I think this
form of parallelism is called in the Haskell community. If wanting to
use explicit threads, using STM or Channels might be a safer choice in
replace of some of the MVar's to avoid any chance of deadlock.
http://community.haskell.org/~simonmar/par-tutorial.pdf
Final thing, be careful of the fact that MVar's aren't strict:
Haven't run your code so can't say but on the surface it looks like
this may be a problem for your current code.
Cheers,
David
Sure. The danger is as always with threaded programming that extending
/ maintenance is harder. I had to think carefully when reading your
code about the order of various takes and puts. There isn't anything
'wrong' with the method you chose but given you're writing this for
fun / experience I think other forms of parallelism in Haskell are
more 'beautiful'.
> I'll take a look at the strategies. They look... intimidating.
Yeah they are a little but I think the tutorial Simon Marlow wrote
recently and also recent changes in the design with a lot more
infrastructure around now to help in using the spark parallel facility
should go a long way to changing this.