[Haskell-cafe] Parallel Haskell stories

John D. Ramsdell ramsdell0 at gmail.com
Fri Mar 11 00:08:23 CET 2011


On Thu, Mar 10, 2011 at 6:04 PM, John D. Ramsdell <ramsdell0 at gmail.com> wrote:
> At the code level, all that is done is replace one map call with a
> parallelized version of map that I saw in one of your papers:
>
> #if defined HAVE_PAR
> parMap :: (a -> b) -> [a] -> [b]
> parMap _ [] = []

Opps.  Please delete the #if line.  In the actual code, I have
preserved the ability to compile CPSA using GHC 6.8 by using the C
preprocessor as follows:

#if defined HAVE_PAR

parMap :: (a -> b) -> [a] -> [b]
parMap _ [] = []
parMap f (x:xs) =
    par y (pseq ys (y:ys))
    where
      y = f x
      ys = parMap f xs

#else

parMap :: (a -> b) -> [a] -> [b]
parMap = map

#endif

John



More information about the Haskell-Cafe mailing list