I just noticed, thanks to some testing of the parallelism support in 6.6 by Satnam Singh, that Control.Parallel exports seq when in fact it should probably export pseq.

The difference is subtle. The semantics of seq and pseq are identical; however, GHC can see that seq is strict in both its arguments and hence could choose to evaluate them in either order, whereas pseq is only strict in its first argument as far as the strictness analyser is concerned. The point is that pseq is useful for controlling evaluation order, which is what you want for adding parallelism to a program. seq, on the other hand, is not useful for controlling evaluation order. The documentation in 6.6 is also incorrect on this point.

pseq is currently not exported by Control.Parallel, this is an oversight on my part, you have to import it from GHC.Conc for now. For 6.8 we'll export pseq from Control.Parallel instead of seq.

Incedentally, the fixity of par is also wrong in 6.6: it should be infixr 0, but in fact it has the default fixity of infixl 0. This means if you write an expression like 'x `par` y `seq` z', it isn't doing what you think. Workaround: either use parentheses, or define your own par with the right fixity.

Cheers,
        Simon
_______________________________________________
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Reply via email to