Parallelism in Haskell can be expressed using the
Eval Monad from
Control.Parallel.Strategies, using the
rseq functions (among others).
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... return (a,b)
main above will execute and "return" immediately, while the two values,
b are computed in the background through
Note: ensure you compile with
-threaded for parallel execution to occur.