-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Run lifted IO operations asynchronously and wait for their results
--   
--   This package provides IO operations from <tt>async</tt> package lifted
--   to any instance of <a>MonadBase</a> or <a>MonadBaseControl</a>.
@package lifted-async
@version 0.9.0


-- | This is a wrapped version of <tt>Control.Concurrent.Async</tt> with
--   types generalized from <a>IO</a> to all monads in either
--   <a>MonadBase</a> or <a>MonadBaseControl</a>.
--   
--   All the functions restore the monadic effects in the forked
--   computation unless specified otherwise.
--   
--   If your monad stack satisfies <tt><a>StM</a> m a ~ a</tt> (e.g. the
--   reader monad), consider using
--   <tt>Control.Concurrent.Async.Lifted.Safe</tt> module, which prevents
--   you from messing up monadic effects.
module Control.Concurrent.Async.Lifted

-- | An asynchronous action spawned by <a>async</a> or <a>withAsync</a>.
--   Asynchronous actions are executed in a separate thread, and operations
--   are provided for waiting for asynchronous actions to complete and
--   obtaining their results (see e.g. <a>wait</a>).
data Async a :: * -> *

-- | Generalized version of <a>async</a>.
async :: MonadBaseControl IO m => m a -> m (Async (StM m a))

-- | Generalized version of <a>asyncBound</a>.
asyncBound :: MonadBaseControl IO m => m a -> m (Async (StM m a))

-- | Generalized version of <a>asyncOn</a>.
asyncOn :: MonadBaseControl IO m => Int -> m a -> m (Async (StM m a))

-- | Generalized version of <a>asyncWithUnmask</a>.
asyncWithUnmask :: MonadBaseControl IO m => ((forall b. m b -> m b) -> m a) -> m (Async (StM m a))

-- | Generalized version of <a>asyncOnWithUnmask</a>.
asyncOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall b. m b -> m b) -> m a) -> m (Async (StM m a))

-- | Generalized version of <a>withAsync</a>.
withAsync :: MonadBaseControl IO m => m a -> (Async (StM m a) -> m b) -> m b

-- | Generalized version of <a>withAsyncBound</a>.
withAsyncBound :: MonadBaseControl IO m => m a -> (Async (StM m a) -> m b) -> m b

-- | Generalized version of <a>withAsyncOn</a>.
withAsyncOn :: MonadBaseControl IO m => Int -> m a -> (Async (StM m a) -> m b) -> m b

-- | Generalized version of <a>withAsyncWithUnmask</a>.
withAsyncWithUnmask :: MonadBaseControl IO m => ((forall c. m c -> m c) -> m a) -> (Async (StM m a) -> m b) -> m b

-- | Generalized version of <a>withAsyncOnWithUnmask</a>.
withAsyncOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall c. m c -> m c) -> m a) -> (Async (StM m a) -> m b) -> m b

-- | Generalized version of <a>wait</a>.
wait :: MonadBaseControl IO m => Async (StM m a) -> m a

-- | Generalized version of <a>poll</a>.
poll :: MonadBaseControl IO m => Async (StM m a) -> m (Maybe (Either SomeException a))

-- | Generalized version of <a>waitCatch</a>.
waitCatch :: MonadBaseControl IO m => Async (StM m a) -> m (Either SomeException a)

-- | Generalized version of <a>cancel</a>.
--   
--   NOTE: This function discards the monadic effects besides IO in the
--   forked computation.
cancel :: MonadBase IO m => Async a -> m ()

-- | Generalized version of <a>cancelWith</a>.
--   
--   NOTE: This function discards the monadic effects besides IO in the
--   forked computation.
cancelWith :: (MonadBase IO m, Exception e) => Async a -> e -> m ()

-- | Returns the <a>ThreadId</a> of the thread running the given
--   <a>Async</a>.
asyncThreadId :: Async a -> ThreadId

-- | A version of <a>wait</a> that can be used inside an STM transaction.
waitSTM :: Async a -> STM a

-- | A version of <a>poll</a> that can be used inside an STM transaction.
pollSTM :: Async a -> STM (Maybe (Either SomeException a))

-- | A version of <a>waitCatch</a> that can be used inside an STM
--   transaction.
waitCatchSTM :: Async a -> STM (Either SomeException a)

-- | Generalized version of <a>waitAny</a>.
waitAny :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), a)

-- | Generalized version of <a>waitAnyCatch</a>.
waitAnyCatch :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), Either SomeException a)

-- | Generalized version of <a>waitAnyCancel</a>.
waitAnyCancel :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), a)

-- | Generalized version of <a>waitAnyCatchCancel</a>.
waitAnyCatchCancel :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), Either SomeException a)

-- | Generalized version of <a>waitEither</a>.
waitEither :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either a b)

-- | Generalized version of <a>waitEitherCatch</a>.
waitEitherCatch :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either (Either SomeException a) (Either SomeException b))

-- | Generalized version of <a>waitEitherCancel</a>.
waitEitherCancel :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either a b)

-- | Generalized version of <a>waitEitherCatchCancel</a>.
waitEitherCatchCancel :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either (Either SomeException a) (Either SomeException b))

-- | Generalized version of <a>waitEither_</a>.
--   
--   NOTE: This function discards the monadic effects besides IO in the
--   forked computation.
waitEither_ :: MonadBase IO m => Async a -> Async b -> m ()

-- | Generalized version of <a>waitBoth</a>.
waitBoth :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (a, b)

-- | A version of <a>waitAny</a> that can be used inside an STM
--   transaction.
waitAnySTM :: [Async a] -> STM (Async a, a)

-- | A version of <a>waitAnyCatch</a> that can be used inside an STM
--   transaction.
waitAnyCatchSTM :: [Async a] -> STM (Async a, Either SomeException a)

-- | A version of <a>waitEither</a> that can be used inside an STM
--   transaction.
waitEitherSTM :: Async a -> Async b -> STM (Either a b)

-- | A version of <a>waitEitherCatch</a> that can be used inside an STM
--   transaction.
waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b))

-- | A version of <a>waitEither_</a> that can be used inside an STM
--   transaction.
waitEitherSTM_ :: Async a -> Async b -> STM ()

-- | A version of <a>waitBoth</a> that can be used inside an STM
--   transaction.
waitBothSTM :: Async a -> Async b -> STM (a, b)

-- | Generalized version of <a>link</a>.
link :: MonadBase IO m => Async a -> m ()

-- | Generalized version of <a>link2</a>.
link2 :: MonadBase IO m => Async a -> Async b -> m ()

-- | Generalized version of <a>race</a>.
race :: MonadBaseControl IO m => m a -> m b -> m (Either a b)

-- | Generalized version of <a>race_</a>.
--   
--   NOTE: This function discards the monadic effects besides IO in the
--   forked computation.
race_ :: MonadBaseControl IO m => m a -> m b -> m ()

-- | Generalized version of <a>concurrently</a>.
concurrently :: MonadBaseControl IO m => m a -> m b -> m (a, b)

-- | Generalized version of <a>mapConcurrently</a>.
mapConcurrently :: (Traversable t, MonadBaseControl IO m) => (a -> m b) -> t a -> m (t b)

-- | Generalized version of <a>forConcurrently</a>.
forConcurrently :: (Traversable t, MonadBaseControl IO m) => t a -> (a -> m b) -> m (t b)

-- | Generalized version of <a>Concurrently</a>.
--   
--   A value of type <tt><a>Concurrently</a> m a</tt> is an IO-based
--   operation that can be composed with other <a>Concurrently</a> values,
--   using the <a>Applicative</a> and <a>Alternative</a> instances.
--   
--   Calling <a>runConcurrently</a> on a value of type
--   <tt><a>Concurrently</a> m a</tt> will execute the IO-based lifted
--   operations it contains concurrently, before delivering the result of
--   type <tt>a</tt>.
--   
--   For example
--   
--   <pre>
--   (page1, page2, page3) &lt;- <a>runConcurrently</a> $ (,,)
--     <a>&lt;$&gt;</a> <a>Concurrently</a> (getURL "url1")
--     <a>&lt;*&gt;</a> <a>Concurrently</a> (getURL "url2")
--     <a>&lt;*&gt;</a> <a>Concurrently</a> (getURL "url3")
--   </pre>
newtype Concurrently m a
Concurrently :: m a -> Concurrently m a
[runConcurrently] :: Concurrently m a -> m a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Concurrent.Async.Lifted.Concurrently m)
instance Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO m => GHC.Base.Applicative (Control.Concurrent.Async.Lifted.Concurrently m)
instance Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO m => GHC.Base.Alternative (Control.Concurrent.Async.Lifted.Concurrently m)
instance (Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO m, Data.Semigroup.Semigroup a) => Data.Semigroup.Semigroup (Control.Concurrent.Async.Lifted.Concurrently m a)
instance (Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO m, Data.Semigroup.Semigroup a, GHC.Base.Monoid a) => GHC.Base.Monoid (Control.Concurrent.Async.Lifted.Concurrently m a)


-- | This is a safe variant of <tt>Control.Concurrent.Async.Lifted</tt>.
--   
--   This module assumes your monad stack to satisfy <tt><a>StM</a> m a ~
--   a</tt> so you can't mess up monadic effects. If your monad stack is
--   stateful, use <tt>Control.Concurrent.Async.Lifted</tt> with special
--   care.
module Control.Concurrent.Async.Lifted.Safe

-- | An asynchronous action spawned by <a>async</a> or <a>withAsync</a>.
--   Asynchronous actions are executed in a separate thread, and operations
--   are provided for waiting for asynchronous actions to complete and
--   obtaining their results (see e.g. <a>wait</a>).
data Async a :: * -> *

-- | Most of the functions in this module have <tt><a>Forall</a>
--   (<a>Pure</a> m)</tt> in their constraints, which means they require
--   the monad <tt>m</tt> satisfies <tt><a>StM</a> m a ~ a</tt> for all
--   <tt>a</tt>.
class StM m a ~ a => Pure m a

-- | A representation of the quantified constraint <tt>forall a. p a</tt>.

-- | Generalized version of <a>async</a>.
async :: forall m a. (MonadBaseControl IO m, Forall (Pure m)) => m a -> m (Async a)

-- | Generalized version of <a>asyncBound</a>.
asyncBound :: forall m a. (MonadBaseControl IO m, Forall (Pure m)) => m a -> m (Async a)

-- | Generalized version of <a>asyncOn</a>.
asyncOn :: forall m a. (MonadBaseControl IO m, Forall (Pure m)) => Int -> m a -> m (Async a)

-- | Generalized version of <a>asyncWithUnmask</a>.
asyncWithUnmask :: forall m a. (MonadBaseControl IO m, Forall (Pure m)) => ((forall b. m b -> m b) -> m a) -> m (Async a)

-- | Generalized version of <a>asyncOnWithUnmask</a>.
asyncOnWithUnmask :: forall m a. (MonadBaseControl IO m, Forall (Pure m)) => Int -> ((forall b. m b -> m b) -> m a) -> m (Async a)

-- | Generalized version of <a>withAsync</a>.
withAsync :: forall m a b. (MonadBaseControl IO m, Forall (Pure m)) => m a -> (Async a -> m b) -> m b

-- | Generalized version of <a>withAsyncBound</a>.
withAsyncBound :: forall m a b. (MonadBaseControl IO m, Forall (Pure m)) => m a -> (Async a -> m b) -> m b

-- | Generalized version of <a>withAsyncOn</a>.
withAsyncOn :: forall m a b. (MonadBaseControl IO m, Forall (Pure m)) => Int -> m a -> (Async a -> m b) -> m b

-- | Generalized version of <a>withAsyncWithUnmask</a>.
withAsyncWithUnmask :: forall m a b. (MonadBaseControl IO m, Forall (Pure m)) => ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b

-- | Generalized version of <a>withAsyncOnWithUnmask</a>.
withAsyncOnWithUnmask :: forall m a b. (MonadBaseControl IO m, Forall (Pure m)) => Int -> ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b

-- | Generalized version of <a>wait</a>.
wait :: forall m a. (MonadBase IO m, Forall (Pure m)) => Async a -> m a

-- | Generalized version of <a>poll</a>.
poll :: forall m a. (MonadBase IO m, Forall (Pure m)) => Async a -> m (Maybe (Either SomeException a))

-- | Generalized version of <a>waitCatch</a>.
waitCatch :: forall m a. (MonadBase IO m, Forall (Pure m)) => Async a -> m (Either SomeException a)

-- | Generalized version of <a>cancel</a>.
cancel :: MonadBase IO m => Async a -> m ()

-- | Generalized version of <a>cancelWith</a>.
cancelWith :: (MonadBase IO m, Exception e) => Async a -> e -> m ()

-- | Returns the <a>ThreadId</a> of the thread running the given
--   <a>Async</a>.
asyncThreadId :: Async a -> ThreadId

-- | A version of <a>wait</a> that can be used inside an STM transaction.
waitSTM :: Async a -> STM a

-- | A version of <a>poll</a> that can be used inside an STM transaction.
pollSTM :: Async a -> STM (Maybe (Either SomeException a))

-- | A version of <a>waitCatch</a> that can be used inside an STM
--   transaction.
waitCatchSTM :: Async a -> STM (Either SomeException a)

-- | Generalized version of <a>waitAny</a>.
waitAny :: forall m a. (MonadBase IO m, Forall (Pure m)) => [Async a] -> m (Async a, a)

-- | Generalized version of <a>waitAnyCatch</a>.
waitAnyCatch :: forall m a. (MonadBase IO m, Forall (Pure m)) => [Async a] -> m (Async a, Either SomeException a)

-- | Generalized version of <a>waitAnyCancel</a>.
waitAnyCancel :: forall m a. (MonadBase IO m, Forall (Pure m)) => [Async a] -> m (Async a, a)

-- | Generalized version of <a>waitAnyCatchCancel</a>.
waitAnyCatchCancel :: forall m a. (MonadBase IO m, Forall (Pure m)) => [Async a] -> m (Async a, Either SomeException a)

-- | Generalized version of <a>waitEither</a>.
waitEither :: forall m a b. (MonadBase IO m, Forall (Pure m)) => Async a -> Async b -> m (Either a b)

-- | Generalized version of <a>waitEitherCatch</a>.
waitEitherCatch :: forall m a b. (MonadBase IO m, Forall (Pure m)) => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))

-- | Generalized version of <a>waitEitherCancel</a>.
waitEitherCancel :: forall m a b. (MonadBase IO m, Forall (Pure m)) => Async a -> Async b -> m (Either a b)

-- | Generalized version of <a>waitEitherCatchCancel</a>.
waitEitherCatchCancel :: forall m a b. (MonadBase IO m, Forall (Pure m)) => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))

-- | Generalized version of <a>waitEither_</a>
waitEither_ :: MonadBase IO m => Async a -> Async b -> m ()

-- | Generalized version of <a>waitBoth</a>.
waitBoth :: forall m a b. (MonadBase IO m, Forall (Pure m)) => Async a -> Async b -> m (a, b)

-- | A version of <a>waitAny</a> that can be used inside an STM
--   transaction.
waitAnySTM :: [Async a] -> STM (Async a, a)

-- | A version of <a>waitAnyCatch</a> that can be used inside an STM
--   transaction.
waitAnyCatchSTM :: [Async a] -> STM (Async a, Either SomeException a)

-- | A version of <a>waitEither</a> that can be used inside an STM
--   transaction.
waitEitherSTM :: Async a -> Async b -> STM (Either a b)

-- | A version of <a>waitEitherCatch</a> that can be used inside an STM
--   transaction.
waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b))

-- | A version of <a>waitEither_</a> that can be used inside an STM
--   transaction.
waitEitherSTM_ :: Async a -> Async b -> STM ()

-- | A version of <a>waitBoth</a> that can be used inside an STM
--   transaction.
waitBothSTM :: Async a -> Async b -> STM (a, b)

-- | Generalized version of <a>link</a>.
link :: MonadBase IO m => Async a -> m ()

-- | Generalized version of <a>link2</a>.
link2 :: MonadBase IO m => Async a -> Async b -> m ()

-- | Generalized version of <a>race</a>.
race :: forall m a b. (MonadBaseControl IO m, Forall (Pure m)) => m a -> m b -> m (Either a b)

-- | Generalized version of <a>race_</a>.
race_ :: forall m a b. (MonadBaseControl IO m, Forall (Pure m)) => m a -> m b -> m ()

-- | Generalized version of <a>concurrently</a>.
concurrently :: forall m a b. (MonadBaseControl IO m, Forall (Pure m)) => m a -> m b -> m (a, b)

-- | Generalized version of <a>mapConcurrently</a>.
mapConcurrently :: (Traversable t, MonadBaseControl IO m, Forall (Pure m)) => (a -> m b) -> t a -> m (t b)

-- | Generalized version of <a>Concurrently</a>.
--   
--   A value of type <tt><a>Concurrently</a> m a</tt> is an IO-based
--   operation that can be composed with other <a>Concurrently</a> values,
--   using the <a>Applicative</a> and <a>Alternative</a> instances.
--   
--   Calling <a>runConcurrently</a> on a value of type
--   <tt><a>Concurrently</a> m a</tt> will execute the IO-based lifted
--   operations it contains concurrently, before delivering the result of
--   type <tt>a</tt>.
--   
--   For example
--   
--   <pre>
--   (page1, page2, page3) &lt;- <a>runConcurrently</a> $ (,,)
--     <a>&lt;$&gt;</a> <a>Concurrently</a> (getURL "url1")
--     <a>&lt;*&gt;</a> <a>Concurrently</a> (getURL "url2")
--     <a>&lt;*&gt;</a> <a>Concurrently</a> (getURL "url3")
--   </pre>
data Concurrently m a
[Concurrently] :: Forall (Pure m) => {runConcurrently :: m a} -> Concurrently m a
instance Control.Monad.Trans.Control.StM m a ~ a => Control.Concurrent.Async.Lifted.Safe.Pure m a
instance GHC.Base.Functor m => GHC.Base.Functor (Control.Concurrent.Async.Lifted.Safe.Concurrently m)
instance (Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO m, Data.Constraint.Forall.Forall (Control.Concurrent.Async.Lifted.Safe.Pure m)) => GHC.Base.Applicative (Control.Concurrent.Async.Lifted.Safe.Concurrently m)
instance (Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO m, Data.Constraint.Forall.Forall (Control.Concurrent.Async.Lifted.Safe.Pure m)) => GHC.Base.Alternative (Control.Concurrent.Async.Lifted.Safe.Concurrently m)
instance (Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO m, Data.Semigroup.Semigroup a, Data.Constraint.Forall.Forall (Control.Concurrent.Async.Lifted.Safe.Pure m)) => Data.Semigroup.Semigroup (Control.Concurrent.Async.Lifted.Safe.Concurrently m a)
instance (Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO m, Data.Semigroup.Semigroup a, GHC.Base.Monoid a, Data.Constraint.Forall.Forall (Control.Concurrent.Async.Lifted.Safe.Pure m)) => GHC.Base.Monoid (Control.Concurrent.Async.Lifted.Safe.Concurrently m a)
