[Haskell-cafe] Standard implementation of asynchronous helpers?

Tristan Seligmann mithrandi at mithrandi.net
Sat Jan 18 15:18:20 UTC 2014


I was wondering if a standard implementation of these helpers (or
something similar) existed somewhere:

startAsync :: IO a -> IO (MVar a)
startAsync action = do
    var <- newEmptyMVar
    forkIO $ action >>= putMVar var
    return var

wait :: MVar a -> IO a
wait = readMVar

I've found a few throwaway examples that implement something similar,
and I can imagine some improvements already (I guess the MVar should
be wrapped, for example, and some higher) but I was unable to find any
released library that does something like this.

Is it just too trivial for anyone to have bothered?
-- 
mithrandi, i Ainil en-Balandor, a faer Ambar


More information about the Haskell-Cafe mailing list