| Stability | experimental |
|---|---|
| Maintainer | Mitsutoshi Aoe <maoe@foldr.in> |
| Safe Haskell | None |
Control.Concurrent.Async.Lifted
Contents
Description
This is a wrapped version of Control.Concurrent.Async with types generalized from IO to all monads in either MonadBase or MonadBaseControl.
- data Async a
- async :: MonadBaseControl IO m => m a -> m (Async (StM m a))
- asyncBound :: MonadBaseControl IO m => m a -> m (Async (StM m a))
- asyncOn :: MonadBaseControl IO m => Int -> m a -> m (Async (StM m a))
- asyncWithUnmask :: MonadBaseControl IO m => ((forall b. m b -> m b) -> m a) -> m (Async (StM m a))
- asyncOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall b. m b -> m b) -> m a) -> m (Async (StM m a))
- withAsync :: MonadBaseControl IO m => m a -> (Async (StM m a) -> m b) -> m b
- withAsyncBound :: MonadBaseControl IO m => m a -> (Async (StM m a) -> m b) -> m b
- withAsyncOn :: MonadBaseControl IO m => Int -> m a -> (Async (StM m a) -> m b) -> m b
- withAsyncWithUnmask :: MonadBaseControl IO m => ((forall c. m c -> m c) -> m a) -> (Async (StM m a) -> m b) -> m b
- withAsyncOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall c. m c -> m c) -> m a) -> (Async (StM m a) -> m b) -> m b
- wait :: MonadBaseControl IO m => Async (StM m a) -> m a
- poll :: MonadBaseControl IO m => Async (StM m a) -> m (Maybe (Either SomeException a))
- waitCatch :: MonadBaseControl IO m => Async (StM m a) -> m (Either SomeException a)
- cancel :: MonadBase IO m => Async (StM m a) -> m ()
- cancelWith :: (MonadBase IO m, Exception e) => Async (StM m a) -> e -> m ()
- asyncThreadId :: Async a -> ThreadId
- waitSTM :: Async a -> STM a
- pollSTM :: Async a -> STM (Maybe (Either SomeException a))
- waitCatchSTM :: Async a -> STM (Either SomeException a)
- waitAny :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), a)
- waitAnyCatch :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), Either SomeException a)
- waitAnyCancel :: MonadBase IO m => [Async a] -> m (Async a, a)
- waitAnyCatchCancel :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), Either SomeException a)
- waitEither :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either a b)
- waitEitherCatch :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either (Either SomeException a) (Either SomeException b))
- waitEitherCancel :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either a b)
- waitEitherCatchCancel :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either (Either SomeException a) (Either SomeException b))
- waitEither_ :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m ()
- waitBoth :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (a, b)
- link :: MonadBase IO m => Async (StM m a) -> m ()
- link2 :: MonadBase IO m => Async (StM m a) -> Async (StM m b) -> m ()
- race :: MonadBaseControl IO m => m a -> m b -> m (Either a b)
- race_ :: MonadBaseControl IO m => m a -> m b -> m ()
- concurrently :: MonadBaseControl IO m => m a -> m b -> m (a, b)
- mapConcurrently :: (Traversable t, MonadBaseControl IO m) => (a -> m b) -> t a -> m (t b)
- newtype Concurrently a = Concurrently {
- runConcurrently :: IO a
Asynchronous actions
data Async a
Spawning
asyncBound :: MonadBaseControl IO m => m a -> m (Async (StM m a))Source
Generalized version of asyncBound.
asyncOn :: MonadBaseControl IO m => Int -> m a -> m (Async (StM m a))Source
Generalized version of asyncOn.
asyncWithUnmask :: MonadBaseControl IO m => ((forall b. m b -> m b) -> m a) -> m (Async (StM m a))Source
Generalized version of asyncWithUnmask.
asyncOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall b. m b -> m b) -> m a) -> m (Async (StM m a))Source
Generalized version of asyncOnWithUnmask.
Spawning with automatic cancelation
withAsync :: MonadBaseControl IO m => m a -> (Async (StM m a) -> m b) -> m bSource
Generalized version of withAsync.
withAsyncBound :: MonadBaseControl IO m => m a -> (Async (StM m a) -> m b) -> m bSource
Generalized version of withAsyncBound.
withAsyncOn :: MonadBaseControl IO m => Int -> m a -> (Async (StM m a) -> m b) -> m bSource
Generalized version of withAsyncOn.
withAsyncWithUnmask :: MonadBaseControl IO m => ((forall c. m c -> m c) -> m a) -> (Async (StM m a) -> m b) -> m bSource
Generalized version of withAsyncWithUnmask.
withAsyncOnWithUnmask :: MonadBaseControl IO m => Int -> ((forall c. m c -> m c) -> m a) -> (Async (StM m a) -> m b) -> m bSource
Generalized version of withAsyncOnWithUnmask.
Quering Asyncs
poll :: MonadBaseControl IO m => Async (StM m a) -> m (Maybe (Either SomeException a))Source
Generalized version of poll.
waitCatch :: MonadBaseControl IO m => Async (StM m a) -> m (Either SomeException a)Source
Generalized version of waitCatch.
cancelWith :: (MonadBase IO m, Exception e) => Async (StM m a) -> e -> m ()Source
Generalized version of cancelWith.
asyncThreadId :: Async a -> ThreadId
STM operations
pollSTM :: Async a -> STM (Maybe (Either SomeException a))
A version of poll that can be used inside an STM transaction.
waitCatchSTM :: Async a -> STM (Either SomeException a)
A version of waitCatch that can be used inside an STM transaction.
Waiting for multiple Asyncs
waitAny :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), a)Source
Generalized version of waitAny.
waitAnyCatch :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), Either SomeException a)Source
Generalized version of waitAnyCatch.
waitAnyCancel :: MonadBase IO m => [Async a] -> m (Async a, a)Source
Generalized version of waitAnyCancel.
waitAnyCatchCancel :: MonadBaseControl IO m => [Async (StM m a)] -> m (Async (StM m a), Either SomeException a)Source
Generalized version of waitAnyCatchCancel.
waitEither :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either a b)Source
Generalized version of waitEither.
waitEitherCatch :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either (Either SomeException a) (Either SomeException b))Source
Generalized version of waitEitherCatch.
waitEitherCancel :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either a b)Source
Generalized version of waitEitherCancel.
waitEitherCatchCancel :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (Either (Either SomeException a) (Either SomeException b))Source
Generalized version of waitEitherCatchCancel.
waitEither_ :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m ()Source
Generalized version of waitEither_.
waitBoth :: MonadBaseControl IO m => Async (StM m a) -> Async (StM m b) -> m (a, b)Source
Generalized version of waitBoth.
Linking
link2 :: MonadBase IO m => Async (StM m a) -> Async (StM m b) -> m ()Source
Generalized version of link2.
Convenient utilities
race_ :: MonadBaseControl IO m => m a -> m b -> m ()Source
Generalized version of race_.
concurrently :: MonadBaseControl IO m => m a -> m b -> m (a, b)Source
Generalized version of concurrently.
mapConcurrently :: (Traversable t, MonadBaseControl IO m) => (a -> m b) -> t a -> m (t b)Source
Generalized version of mapConcurrently.
newtype Concurrently a
A value of type Concurrently a is an IO operation that can be composed with other Concurrently values, using the Applicative and Alternative instances.
Calling runConcurrently on a value of type Concurrently a will execute the IO operations it contains concurrently, before delivering the result of type a.
For example
(page1, page2, page3) <- runConcurrently $ (,,) <$> Concurrently (getURL "url1") <*> Concurrently (getURL "url2") <*> Concurrently (getURL "url3")
Constructors
| Concurrently | |
Fields
| |