[Haskell] parallel seq

Scherrer, Chad Chad.Scherrer at pnl.gov
Tue Apr 25 16:34:32 EDT 2006

I was thinking about the dynamic behavior of par, and there's something
that's a little confusing to me. Am I right in understanding that (x
`par` y) evaluates to y, and may or may not evaluate x along the way? 

I think it would be easier to reason about if we knew that x would be
evaluated, either by a newly-spawned thread or by the parent thread. If
I'm understanding this correctly, this could be done by defining

x `pSeq` y = x `par` y `seq` x `seq` y
(seq has higher precedence than par)

When (x `pSeq` y) is evaluated, x may or may not be evaluated by a new
thread. The parent thread continues along evaluating y. Then the parent
makes sure x was evaluated before finally returning y.

I've not seen this approach used before -- Is there something I'm
missing that makes using pSeq as above just silly?


Chad Scherrer
Computational Mathematics Group
Pacific Northwest National Laboratory

"Time flies like an arrow; fruit flies like a banana." -- Groucho Marx

More information about the Haskell mailing list