Standard implementation of asynchronous helpers?

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

E.g. https://hackage.haskell.org/package/async ? On Sat 18 Jan 2014 15:18:20 GMT, Tristan Seligmann wrote:
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?

On Sat, Jan 18, 2014 at 5:26 PM, Niklas Hambüchen
Uh, yes, that seems to be exactly what I was looking for! It's even named the obvious thing, I have no idea why I didn't find it when I was searching. -- mithrandi, i Ainil en-Balandor, a faer Ambar

Yeah it's a nice package, it got some good coverage in Simon's book about concurrency in Haskell
On 18 Jan 2014, at 19:32, Tristan Seligmann
wrote: On Sat, Jan 18, 2014 at 5:26 PM, Niklas Hambüchen
wrote: E.g. https://hackage.haskell.org/package/async ? Uh, yes, that seems to be exactly what I was looking for! It's even named the obvious thing, I have no idea why I didn't find it when I was searching. -- mithrandi, i Ainil en-Balandor, a faer Ambar _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Dan Frumin
-
Niklas Hambüchen
-
Tristan Seligmann