module Lifetimes.Async (acquireAsync) where
import Control.Concurrent.Async (Async, async, cancel, waitCatch)
import Lifetimes
import Zhp
acquireAsync :: IO a -> Acquire (Async a)
acquireAsync :: forall a. IO a -> Acquire (Async a)
acquireAsync IO a
io = forall a. IO a -> (a -> IO ()) -> Acquire a
mkAcquire (forall a. IO a -> IO (Async a)
async IO a
io) (\Async a
a -> forall a. Async a -> IO ()
cancel Async a
a forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall a. Async a -> IO (Either SomeException a)
waitCatch Async a
a)