[Haskell-cafe] Looking for documentation on Control.Parallel.Strategies

Jefferson Heard jeff at renci.org
Fri Feb 16 15:16:40 EST 2007


Is there anything that documents this further than the Haddock documentation 
available from Haskell.org or the GHC pages?  I've gotten some basic 
parallelism to work using parMap and using >|| and >|, but I had a fold and a 
map that I could logically compute at the same time.  

I found this example for quicksort using GPH:

import Strategies


main = print (quicksort ([999,998..0]::[Int]))

quicksort :: (Ord a, NFData a) => [a] -> [a]
quicksort [] = []
quicksort [x] = [x]
quicksort (x:xs) = (lo ++ (x:hi)) `using` strategy
	where
	lo = quicksort [ y | y <- xs, y < x]
	hi = quicksort [ y | y <- xs, y >= x]
	strategy result = rnf lo `par`
			rnf hi `par`
		  	rnf result

Is the syntax the same for GHC using Control.Parallel.Strategies?  If so, does 
the following execute the two computations from the where clause in parallel?

import Control.Parallel
import Control.Parallel.Strategies

stats bigList summation mean = (stddev, proportions) `using` strategy
	where 
	stddev = sqrt (fold ((+) . (^2) . (-mean)) 0 bigList)
	proportions = map (/summation) bigList
	strategy result = rnf stddev >|| 
			rnf proportions >|| 
			rnf result

Thanks!
--Jeff


More information about the Haskell-Cafe mailing list