[Haskell-cafe] Parallel executing of actions

Mitar mmitar at gmail.com
Sun Apr 15 12:01:44 EDT 2007


Hi!

Is there a parallel version of mapM_? Like it is for map (parMap)?

I would like to execute actions in parallel as the computation of
necessary data for actions is quite computational heavy. But it does
not matter in which order those actions are executed. (I am rendering
pixels with OpenGL and it does not matter in which order I draw them,
but it matters that for one pixel it takes some time to calculate its
color.)

The example would be:

main :: IO ()
main = do
  -- the order of printed characters is not important
  -- instead of putStrLn there will be a computationally big function
  -- so it would be great if those computations would be done in parallel
  -- and results printed out as they come
  mapM_ rwhnf (putStrLn) ["a","b","c","d"]

Is this possible? Without unsafe functions? And without changing the
semantics of the program.


Mitar


More information about the Haskell-Cafe mailing list