
9 Dec
2009
9 Dec
'09
9:44 p.m.
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)