collector <- newChan let m = 10 sequence $ do d <- [ 0 .. m - 1 ] return $ forkIO $ do let p = sum [ d , d + m .. n ] writeChan collector p xs <- sequence $ replicate ( fromIntegral m ) $ readChan collector print $ sum xs
ghc -smp --make Foo -o Foo; ./Foo +RTS -N2
http://hackage.haskell.org/trac/ghc/wiki/GhcConcurrency
http://pugs.blogs.com/pugs/2006/10/smp_paralleliza.html