Implement IO's 'spawn' in terms of other conc primitives

This commit is contained in:
Michael Walker 2014-12-19 06:24:50 +00:00
parent 9361499b01
commit 070d034de9

View File

@ -35,9 +35,9 @@ class Monad m => ConcFuture future m | m -> future where
instance ConcFuture MVar IO where
spawn ma = do
mvar <- newEmptyMVar
void . forkIO $ ma >>= putMVar mvar
return mvar
cvar <- new
fork $ ma >>= put cvar
return cvar
get = readMVar