A similar function that I'm fond of:

forkExec :: IO a -> IO (IO a)
forkExec k
    = do
  result <- newEmptyMVar
  _ <- forkIO $ k >>= putMVar result
  return (takeMVar result)

Although I don't think it can be generalized to non-IO monads.

Antoine


I can't test it right now, but wouldn't the following do the job in the Identity monad?

forkExec :: Identity a -> Identity (Identity a)
forkExec k = let result = runIdentity k
             in result `par` return (Identity result)

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to