Haskell Language Parallelism rseq


We can use rseq :: Strategy a to force an argument to Weak Head Normal Form:

f1 :: [Int]
f1 = [1..100000000]

f2 :: [Int]
f2 = [1..200000000]

main = runEval $ do
  a <- rpar (f1) -- this'll take a while...
  b <- rpar (f2) -- this'll take a while and then some...
  rseq a
  return (a,b)

This subtly changes the semantics of the rpar example; whereas the latter would return immediately whilst computing the values in the background, this example will wait until a can be evaluated to WHNF.