Parallelism in 6.6 and seq vs. pseq

Simon Marlow simonmarhaskell at
Fri Oct 27 09:22:07 EDT 2006

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.


More information about the Glasgow-haskell-users mailing list