[Haskell-cafe] Go parallel

Tim Docker timd at macquarie.com.au
Mon Nov 5 19:13:05 EST 2007

Is it possible to use the forkIO primitive to cause pure computations
to be evaluated in parallel threads?

It seems to me that laziness would always prevent any evaluation until
the result was used in a consuming thread (and hence would occur
serially, in that thread).


-----Original Message-----
From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Bulat Ziganshin
Sent: Tuesday, 6 November 2007 10:59 AM
To: Andrew Coppin
Cc: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] Go parallel

Hello Andrew,

Monday, November 5, 2007, 11:12:33 PM, you wrote:

> How do I alter this to compute fn in multiple threads in parallel? (As

jobs :: [IO()]
let fork job = do mvar <- newEmptyMVar
                  forkIO$ do job; putMVar mvar ()
                  return mvar
tasks <- mapM fork jobs
mapM_ takeMVar tasks

these runs jobs and waits before all them will be finished

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

Haskell-Cafe mailing list
Haskell-Cafe at haskell.org

More information about the Haskell-Cafe mailing list