module Control.Concurrent.Async.Lifted.Safe.Utils
  ( allocateLinkedAsync
  ) where

import ClassyPrelude hiding (cancel)

import Control.Concurrent.Async.Lifted.Safe

import Control.Monad.Trans.Resource


allocateLinkedAsync :: forall m a.
                       MonadResource m
                       => IO a -> m (Async a)
allocateLinkedAsync act = allocate (async act) cancel >>= (\(_k, a) -> a <$ link a)
