| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Effects.Concurrent.Async
Description
Provides the MonadAsync typeclass for async effects. We first present
the class, then the async API implemented via the typeclass.
Since: 0.1
Synopsis
- class Monad m => MonadAsync (m :: Type -> Type) where
- withAsync :: HasCallStack => m a -> (Async a -> m b) -> m b
- withAsyncBound :: HasCallStack => m a -> (Async a -> m b) -> m b
- withAsyncOn :: HasCallStack => Int -> m a -> (Async a -> m b) -> m b
- withAsyncWithUnmask :: HasCallStack => ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b
- withAsyncOnWithUnmask :: HasCallStack => Int -> ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b
- wait :: HasCallStack => Async a -> m a
- poll :: HasCallStack => Async a -> m (Maybe (Either SomeException a))
- waitCatch :: HasCallStack => Async a -> m (Either SomeException a)
- cancel :: HasCallStack => Async a -> m ()
- uninterruptibleCancel :: HasCallStack => Async a -> m ()
- cancelWith :: (Exception e, HasCallStack) => Async a -> e -> m ()
- race :: HasCallStack => m a -> m b -> m (Either a b)
- concurrently :: HasCallStack => m a -> m b -> m (a, b)
- concurrently_ :: HasCallStack => m a -> m b -> m ()
- waitAny :: HasCallStack => [Async a] -> m (Async a, a)
- waitAnyCatch :: HasCallStack => [Async a] -> m (Async a, Either SomeException a)
- waitAnyCancel :: HasCallStack => [Async a] -> m (Async a, a)
- waitAnyCatchCancel :: HasCallStack => [Async a] -> m (Async a, Either SomeException a)
- waitEither :: HasCallStack => Async a -> Async b -> m (Either a b)
- waitEitherCatch :: HasCallStack => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))
- waitEitherCancel :: HasCallStack => Async a -> Async b -> m (Either a b)
- waitEitherCatchCancel :: HasCallStack => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))
- waitEither_ :: HasCallStack => Async a -> Async b -> m ()
- waitBoth :: HasCallStack => Async a -> Async b -> m (a, b)
- async :: HasCallStack => m a -> m (Async a)
- asyncBound :: HasCallStack => m a -> m (Async a)
- asyncOn :: HasCallStack => Int -> m a -> m (Async a)
- asyncWithUnmask :: HasCallStack => ((forall b. m b -> m b) -> m a) -> m (Async a)
- asyncOnWithUnmask :: HasCallStack => Int -> ((forall b. m b -> m b) -> m a) -> m (Async a)
- link :: HasCallStack => Async a -> m ()
- linkOnly :: HasCallStack => (SomeException -> Bool) -> Async a -> m ()
- link2 :: HasCallStack => Async a -> Async b -> m ()
- link2Only :: HasCallStack => (SomeException -> Bool) -> Async a -> Async b -> m ()
- pooledMapConcurrentlyN :: (HasCallStack, Traversable t) => Positive Int -> (a -> m b) -> t a -> m (t b)
- pooledMapConcurrently :: (HasCallStack, Traversable t) => (a -> m b) -> t a -> m (t b)
- pooledMapConcurrentlyN_ :: (Foldable f, HasCallStack) => Positive Int -> (a -> m b) -> f a -> m ()
- pooledMapConcurrently_ :: (Foldable f, HasCallStack) => (a -> m b) -> f a -> m ()
- data Async a
- withAsync :: (MonadAsync m, HasCallStack) => m a -> (Async a -> m b) -> m b
- withAsyncBound :: (MonadAsync m, HasCallStack) => m a -> (Async a -> m b) -> m b
- withAsyncOn :: (MonadAsync m, HasCallStack) => Int -> m a -> (Async a -> m b) -> m b
- withAsyncWithUnmask :: (MonadAsync m, HasCallStack) => ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b
- withAsyncOnWithUnmask :: (MonadAsync m, HasCallStack) => Int -> ((forall c. m c -> m c) -> m a) -> (Async a -> m b) -> m b
- wait :: (MonadAsync m, HasCallStack) => Async a -> m a
- poll :: (MonadAsync m, HasCallStack) => Async a -> m (Maybe (Either SomeException a))
- waitCatch :: (MonadAsync m, HasCallStack) => Async a -> m (Either SomeException a)
- asyncThreadId :: Async a -> ThreadId
- cancel :: (MonadAsync m, HasCallStack) => Async a -> m ()
- uninterruptibleCancel :: (MonadAsync m, HasCallStack) => Async a -> m ()
- cancelWith :: (MonadAsync m, Exception e, HasCallStack) => Async a -> e -> m ()
- data AsyncCancelled = AsyncCancelled
- race :: (MonadAsync m, HasCallStack) => m a -> m b -> m (Either a b)
- race_ :: (HasCallStack, MonadAsync m) => m a -> m b -> m ()
- concurrently :: (MonadAsync m, HasCallStack) => m a -> m b -> m (a, b)
- concurrently_ :: (MonadAsync m, HasCallStack) => m a -> m b -> m ()
- mapConcurrently :: (MonadAsync m, Traversable t) => (a -> m b) -> t a -> m (t b)
- forConcurrently :: (MonadAsync m, Traversable t) => t a -> (a -> m b) -> m (t b)
- mapConcurrently_ :: (MonadAsync m, Foldable f) => (a -> m b) -> f a -> m ()
- forConcurrently_ :: (MonadAsync m, Foldable f) => f a -> (a -> m b) -> m ()
- replicateConcurrently :: MonadAsync m => Int -> m a -> m [a]
- replicateConcurrently_ :: MonadAsync m => Int -> m a -> m ()
- newtype Concurrently (m :: k -> Type) (a :: k) = Concurrently {
- runConcurrently :: m a
- compareAsyncs :: Async a -> Async b -> Ordering
- data STM a
- waitSTM :: Async a -> STM a
- pollSTM :: Async a -> STM (Maybe (Either SomeException a))
- waitCatchSTM :: Async a -> STM (Either SomeException a)
- waitAny :: (MonadAsync m, HasCallStack) => [Async a] -> m (Async a, a)
- waitAnyCatch :: (MonadAsync m, HasCallStack) => [Async a] -> m (Async a, Either SomeException a)
- waitAnyCancel :: (MonadAsync m, HasCallStack) => [Async a] -> m (Async a, a)
- waitAnyCatchCancel :: (MonadAsync m, HasCallStack) => [Async a] -> m (Async a, Either SomeException a)
- waitEither :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (Either a b)
- waitEitherCatch :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))
- waitEitherCancel :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (Either a b)
- waitEitherCatchCancel :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))
- waitEither_ :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m ()
- waitBoth :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (a, b)
- waitAnySTM :: [Async a] -> STM (Async a, a)
- waitAnyCatchSTM :: [Async a] -> STM (Async a, Either SomeException a)
- waitEitherSTM :: Async a -> Async b -> STM (Either a b)
- waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b))
- waitEitherSTM_ :: Async a -> Async b -> STM ()
- waitBothSTM :: Async a -> Async b -> STM (a, b)
- async :: (MonadAsync m, HasCallStack) => m a -> m (Async a)
- asyncBound :: (MonadAsync m, HasCallStack) => m a -> m (Async a)
- asyncOn :: (MonadAsync m, HasCallStack) => Int -> m a -> m (Async a)
- asyncWithUnmask :: (MonadAsync m, HasCallStack) => ((forall b. m b -> m b) -> m a) -> m (Async a)
- asyncOnWithUnmask :: (MonadAsync m, HasCallStack) => Int -> ((forall b. m b -> m b) -> m a) -> m (Async a)
- link :: (MonadAsync m, HasCallStack) => Async a -> m ()
- linkOnly :: (MonadAsync m, HasCallStack) => (SomeException -> Bool) -> Async a -> m ()
- link2 :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m ()
- link2Only :: (MonadAsync m, HasCallStack) => (SomeException -> Bool) -> Async a -> Async b -> m ()
- data ExceptionInLinkedThread = ExceptionInLinkedThread (Async a) SomeException
- pooledMapConcurrentlyN :: (MonadAsync m, HasCallStack, Traversable t) => Positive Int -> (a -> m b) -> t a -> m (t b)
- pooledMapConcurrently :: (MonadAsync m, HasCallStack, Traversable t) => (a -> m b) -> t a -> m (t b)
- pooledMapConcurrentlyN_ :: (MonadAsync m, Foldable f, HasCallStack) => Positive Int -> (a -> m b) -> f a -> m ()
- pooledMapConcurrently_ :: (MonadAsync m, Foldable f, HasCallStack) => (a -> m b) -> f a -> m ()
- pooledForConcurrentlyN :: (HasCallStack, MonadAsync m, Traversable t) => Positive Int -> t a -> (a -> m b) -> m (t b)
- pooledForConcurrently :: (HasCallStack, MonadAsync m, Traversable t) => t a -> (a -> m b) -> m (t b)
- pooledForConcurrentlyN_ :: forall m f a b. (Foldable f, HasCallStack, MonadAsync m) => Positive Int -> f a -> (a -> m b) -> m ()
- pooledForConcurrently_ :: forall m f a b. (Foldable f, HasCallStack, MonadAsync m) => f a -> (a -> m b) -> m ()
- pooledReplicateConcurrentlyN :: (HasCallStack, MonadAsync m) => Positive Int -> Int -> m a -> m [a]
- pooledReplicateConcurrently :: (HasCallStack, MonadAsync m) => Positive Int -> m a -> m [a]
- pooledReplicateConcurrentlyN_ :: (HasCallStack, MonadAsync m) => Positive Int -> Int -> m a -> m ()
- pooledReplicateConcurrently_ :: (HasCallStack, MonadAsync m) => Int -> m a -> m ()
- data SomeException
- class Monad m => MonadThread (m :: Type -> Type)
- data Positive a where
- pattern MkPositive :: a -> Positive a
- mkPositive :: (AMonoid a, Ord a, Show a) => a -> Either String (Positive a)
- mkPositiveTH :: (AMonoid a, Lift a, Ord a, Show a) => a -> Code Q (Positive a)
- unsafePositive :: (AMonoid a, HasCallStack, Ord a, Show a) => a -> Positive a
- (+!) :: (AMonoid a, HasCallStack, Ord a, Show a) => a -> Positive a
Effect
class Monad m => MonadAsync (m :: Type -> Type) where Source #
Represents async effects. API largely follows unliftio's implementation of UnliftIO.Async.
Since: 0.1
Methods
withAsync :: HasCallStack => m a -> (Async a -> m b) -> m b Source #
Lifted withAsync.
Since: 0.1
withAsyncBound :: HasCallStack => m a -> (Async a -> m b) -> m b Source #
Lifted withAsyncBound.
Since: 0.1
withAsyncOn :: HasCallStack => Int -> m a -> (Async a -> m b) -> m b Source #
Lifted withAsyncOn.
Since: 0.1
Arguments
| :: HasCallStack | |
| => ((forall c. m c -> m c) -> m a) | . |
| -> (Async a -> m b) | |
| -> m b |
Lifted withAsyncWithUnmask.
Since: 0.1
withAsyncOnWithUnmask Source #
Arguments
| :: HasCallStack | |
| => Int | . |
| -> ((forall c. m c -> m c) -> m a) | |
| -> (Async a -> m b) | |
| -> m b |
Lifted withAsyncOnWithUnmask.
Since: 0.1
wait :: HasCallStack => Async a -> m a Source #
Lifted wait.
Since: 0.1
poll :: HasCallStack => Async a -> m (Maybe (Either SomeException a)) Source #
Lifted poll.
Since: 0.1
waitCatch :: HasCallStack => Async a -> m (Either SomeException a) Source #
Lifted waitCatch.
Since: 0.1
cancel :: HasCallStack => Async a -> m () Source #
Lifted cancel.
Since: 0.1
uninterruptibleCancel :: HasCallStack => Async a -> m () Source #
Lifted uninterruptibleCancel.
Since: 0.1
cancelWith :: (Exception e, HasCallStack) => Async a -> e -> m () Source #
Lifted cancelWith.
Since: 0.1
race :: HasCallStack => m a -> m b -> m (Either a b) Source #
Lifted race.
Since: 0.1
concurrently :: HasCallStack => m a -> m b -> m (a, b) Source #
Lifted concurrently.
Since: 0.1
concurrently_ :: HasCallStack => m a -> m b -> m () Source #
Lifted concurrently_.
Since: 0.1
waitAny :: HasCallStack => [Async a] -> m (Async a, a) Source #
Lifted waitAny.
Since: 0.1
Arguments
| :: HasCallStack | |
| => [Async a] | . |
| -> m (Async a, Either SomeException a) |
Lifted waitAnyCatch.
Since: 0.1
waitAnyCancel :: HasCallStack => [Async a] -> m (Async a, a) Source #
Lifted waitAnyCancel.
Since: 0.1
Arguments
| :: HasCallStack | |
| => [Async a] | . |
| -> m (Async a, Either SomeException a) |
Lifted waitAnyCatchCancel.
Since: 0.1
waitEither :: HasCallStack => Async a -> Async b -> m (Either a b) Source #
Lifted waitEither.
Since: 0.1
Arguments
| :: HasCallStack | |
| => Async a | . |
| -> Async b | |
| -> m (Either (Either SomeException a) (Either SomeException b)) |
Lifted waitEitherCatch.
Since: 0.1
waitEitherCancel :: HasCallStack => Async a -> Async b -> m (Either a b) Source #
Lifted waitEitherCancel.
Since: 0.1
waitEitherCatchCancel Source #
Arguments
| :: HasCallStack | |
| => Async a | . |
| -> Async b | |
| -> m (Either (Either SomeException a) (Either SomeException b)) |
Lifted waitEitherCatchCancel.
Since: 0.1
waitEither_ :: HasCallStack => Async a -> Async b -> m () Source #
Lifted waitEither_.
Since: 0.1
waitBoth :: HasCallStack => Async a -> Async b -> m (a, b) Source #
Lifted waitBoth.
Since: 0.1
async :: HasCallStack => m a -> m (Async a) Source #
Lifted async.
Since: 0.1
asyncBound :: HasCallStack => m a -> m (Async a) Source #
Lifted asyncBound.
Since: 0.1
asyncOn :: HasCallStack => Int -> m a -> m (Async a) Source #
Lifted asyncOn.
Since: 0.1
asyncWithUnmask :: HasCallStack => ((forall b. m b -> m b) -> m a) -> m (Async a) Source #
Lifted asyncWithUnmask.
Since: 0.1
asyncOnWithUnmask :: HasCallStack => Int -> ((forall b. m b -> m b) -> m a) -> m (Async a) Source #
Lifted asyncOnWithUnmask.
Since: 0.1
link :: HasCallStack => Async a -> m () Source #
Lifted link.
Since: 0.1
linkOnly :: HasCallStack => (SomeException -> Bool) -> Async a -> m () Source #
Lifted linkOnly.
Since: 0.1
link2 :: HasCallStack => Async a -> Async b -> m () Source #
Lifted link2.
Since: 0.1
link2Only :: HasCallStack => (SomeException -> Bool) -> Async a -> Async b -> m () Source #
Lifted link2Only.
Since: 0.1
pooledMapConcurrentlyN Source #
Arguments
| :: (HasCallStack, Traversable t) | |
| => Positive Int | . |
| -> (a -> m b) | |
| -> t a | |
| -> m (t b) |
Lifted pooledMapConcurrentlyN.
Since: 0.1
pooledMapConcurrently Source #
Arguments
| :: (HasCallStack, Traversable t) | |
| => (a -> m b) | . |
| -> t a | |
| -> m (t b) |
Lifted pooledMapConcurrently.
Since: 0.1
pooledMapConcurrentlyN_ Source #
Arguments
| :: (Foldable f, HasCallStack) | |
| => Positive Int | . |
| -> (a -> m b) | |
| -> f a | |
| -> m () |
Lifted pooledMapConcurrentlyN_.
Since: 0.1
pooledMapConcurrently_ Source #
Arguments
| :: (Foldable f, HasCallStack) | |
| => (a -> m b) | . |
| -> f a | |
| -> m () |
Lifted pooledMapConcurrently_.
Since: 0.1
Instances
Asynchronous Actions
An asynchronous action spawned by async or withAsync.
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. wait).
High-level API
Spawning with automatic cancelation
withAsync :: (MonadAsync m, HasCallStack) => m a -> (Async a -> m b) -> m b Source #
Lifted withAsync.
Since: 0.1
withAsyncBound :: (MonadAsync m, HasCallStack) => m a -> (Async a -> m b) -> m b Source #
Lifted withAsyncBound.
Since: 0.1
withAsyncOn :: (MonadAsync m, HasCallStack) => Int -> m a -> (Async a -> m b) -> m b Source #
Lifted withAsyncOn.
Since: 0.1
Arguments
| :: (MonadAsync m, HasCallStack) | |
| => ((forall c. m c -> m c) -> m a) | . |
| -> (Async a -> m b) | |
| -> m b |
Lifted withAsyncWithUnmask.
Since: 0.1
withAsyncOnWithUnmask Source #
Arguments
| :: (MonadAsync m, HasCallStack) | |
| => Int | . |
| -> ((forall c. m c -> m c) -> m a) | |
| -> (Async a -> m b) | |
| -> m b |
Lifted withAsyncOnWithUnmask.
Since: 0.1
Querying Asyncs
wait :: (MonadAsync m, HasCallStack) => Async a -> m a Source #
Lifted wait.
Since: 0.1
poll :: (MonadAsync m, HasCallStack) => Async a -> m (Maybe (Either SomeException a)) Source #
Lifted poll.
Since: 0.1
waitCatch :: (MonadAsync m, HasCallStack) => Async a -> m (Either SomeException a) Source #
Lifted waitCatch.
Since: 0.1
asyncThreadId :: Async a -> ThreadId Source #
cancel :: (MonadAsync m, HasCallStack) => Async a -> m () Source #
Lifted cancel.
Since: 0.1
uninterruptibleCancel :: (MonadAsync m, HasCallStack) => Async a -> m () Source #
Lifted uninterruptibleCancel.
Since: 0.1
cancelWith :: (MonadAsync m, Exception e, HasCallStack) => Async a -> e -> m () Source #
Lifted cancelWith.
Since: 0.1
data AsyncCancelled Source #
The exception thrown by cancel to terminate a thread.
Constructors
| AsyncCancelled |
Instances
| Exception AsyncCancelled Source # | |
Defined in Control.Concurrent.Async.Internal Methods toException :: AsyncCancelled -> SomeException # fromException :: SomeException -> Maybe AsyncCancelled # displayException :: AsyncCancelled -> String # backtraceDesired :: AsyncCancelled -> Bool # | |
| Show AsyncCancelled Source # | |
Defined in Control.Concurrent.Async.Internal Methods showsPrec :: Int -> AsyncCancelled -> ShowS # show :: AsyncCancelled -> String # showList :: [AsyncCancelled] -> ShowS # | |
| Eq AsyncCancelled Source # | |
Defined in Control.Concurrent.Async.Internal Methods (==) :: AsyncCancelled -> AsyncCancelled -> Bool # (/=) :: AsyncCancelled -> AsyncCancelled -> Bool # | |
High-level utilities
race :: (MonadAsync m, HasCallStack) => m a -> m b -> m (Either a b) Source #
Lifted race.
Since: 0.1
race_ :: (HasCallStack, MonadAsync m) => m a -> m b -> m () Source #
Lifted race_.
Since: 0.1
concurrently :: (MonadAsync m, HasCallStack) => m a -> m b -> m (a, b) Source #
Lifted concurrently.
Since: 0.1
concurrently_ :: (MonadAsync m, HasCallStack) => m a -> m b -> m () Source #
Lifted concurrently_.
Since: 0.1
Arguments
| :: (MonadAsync m, Traversable t) | |
| => (a -> m b) | . |
| -> t a | |
| -> m (t b) |
Lifted mapConcurrently.
Since: 0.1
Arguments
| :: (MonadAsync m, Traversable t) | |
| => t a | . |
| -> (a -> m b) | |
| -> m (t b) |
Lifted forConcurrently.
Since: 0.1
Arguments
| :: (MonadAsync m, Foldable f) | |
| => (a -> m b) | . |
| -> f a | |
| -> m () |
Lifted mapConcurrently_.
Since: 0.1
Arguments
| :: (MonadAsync m, Foldable f) | |
| => f a | . |
| -> (a -> m b) | |
| -> m () |
Lifted forConcurrently_.
Since: 0.1
replicateConcurrently :: MonadAsync m => Int -> m a -> m [a] Source #
Lifted replicateConcurrently.
Since: 0.1
replicateConcurrently_ :: MonadAsync m => Int -> m a -> m () Source #
Lifted replicateConcurrently_.
Since: 0.1
newtype Concurrently (m :: k -> Type) (a :: k) Source #
Lifted Concurrently.
Since: 0.1
Constructors
| Concurrently | |
Fields
| |
Instances
compareAsyncs :: Async a -> Async b -> Ordering Source #
Compare two Asyncs that may have different types by their ThreadId.
Specialised operations
STM Operations
A monad supporting atomic memory transactions.
Instances
| MonadCatch STM # | |
Defined in Control.Monad.Catch | |
| MonadThrow STM # | |
Defined in Control.Monad.Catch Methods throwM :: (HasCallStack, Exception e) => e -> STM a # | |
| Alternative STM # | Takes the first non- Since: base-4.8.0.0 |
| Applicative STM # | Since: base-4.8.0.0 |
| Functor STM # | Since: base-4.3.0.0 |
| Monad STM # | Since: base-4.3.0.0 |
| MonadPlus STM # | Takes the first non- Since: base-4.3.0.0 |
| Monoid a => Monoid (STM a) # | Since: base-4.17.0.0 |
| Semigroup a => Semigroup (STM a) # | Since: base-4.17.0.0 |
pollSTM :: Async a -> STM (Maybe (Either SomeException a)) Source #
A version of poll that can be used inside an STM transaction.
waitCatchSTM :: Async a -> STM (Either SomeException a) Source #
A version of waitCatch that can be used inside an STM transaction.
Waiting for multiple Asyncs
waitAny :: (MonadAsync m, HasCallStack) => [Async a] -> m (Async a, a) Source #
Lifted waitAny.
Since: 0.1
Arguments
| :: (MonadAsync m, HasCallStack) | |
| => [Async a] | . |
| -> m (Async a, Either SomeException a) |
Lifted waitAnyCatch.
Since: 0.1
waitAnyCancel :: (MonadAsync m, HasCallStack) => [Async a] -> m (Async a, a) Source #
Lifted waitAnyCancel.
Since: 0.1
Arguments
| :: (MonadAsync m, HasCallStack) | |
| => [Async a] | . |
| -> m (Async a, Either SomeException a) |
Lifted waitAnyCatchCancel.
Since: 0.1
waitEither :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (Either a b) Source #
Lifted waitEither.
Since: 0.1
Arguments
| :: (MonadAsync m, HasCallStack) | |
| => Async a | . |
| -> Async b | |
| -> m (Either (Either SomeException a) (Either SomeException b)) |
Lifted waitEitherCatch.
Since: 0.1
waitEitherCancel :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (Either a b) Source #
Lifted waitEitherCancel.
Since: 0.1
waitEitherCatchCancel Source #
Arguments
| :: (MonadAsync m, HasCallStack) | |
| => Async a | . |
| -> Async b | |
| -> m (Either (Either SomeException a) (Either SomeException b)) |
Lifted waitEitherCatchCancel.
Since: 0.1
waitEither_ :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m () Source #
Lifted waitEither_.
Since: 0.1
waitBoth :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (a, b) Source #
Lifted waitBoth.
Since: 0.1
Waiting for multiple Asyncs in STM
waitAnySTM :: [Async a] -> STM (Async a, a) Source #
A version of waitAny that can be used inside an STM transaction.
Since: async-2.1.0
waitAnyCatchSTM :: [Async a] -> STM (Async a, Either SomeException a) Source #
A version of waitAnyCatch that can be used inside an STM transaction.
Since: async-2.1.0
waitEitherSTM :: Async a -> Async b -> STM (Either a b) Source #
A version of waitEither that can be used inside an STM transaction.
Since: async-2.1.0
waitEitherCatchSTM :: Async a -> Async b -> STM (Either (Either SomeException a) (Either SomeException b)) Source #
A version of waitEitherCatch that can be used inside an STM transaction.
Since: async-2.1.0
waitEitherSTM_ :: Async a -> Async b -> STM () Source #
A version of waitEither_ that can be used inside an STM transaction.
Since: async-2.1.0
waitBothSTM :: Async a -> Async b -> STM (a, b) Source #
A version of waitBoth that can be used inside an STM transaction.
Since: async-2.1.0
Low-level API
Spawning (low-level API)
async :: (MonadAsync m, HasCallStack) => m a -> m (Async a) Source #
Lifted async.
Since: 0.1
asyncBound :: (MonadAsync m, HasCallStack) => m a -> m (Async a) Source #
Lifted asyncBound.
Since: 0.1
asyncOn :: (MonadAsync m, HasCallStack) => Int -> m a -> m (Async a) Source #
Lifted asyncOn.
Since: 0.1
asyncWithUnmask :: (MonadAsync m, HasCallStack) => ((forall b. m b -> m b) -> m a) -> m (Async a) Source #
Lifted asyncWithUnmask.
Since: 0.1
asyncOnWithUnmask :: (MonadAsync m, HasCallStack) => Int -> ((forall b. m b -> m b) -> m a) -> m (Async a) Source #
Lifted asyncOnWithUnmask.
Since: 0.1
Linking
link :: (MonadAsync m, HasCallStack) => Async a -> m () Source #
Lifted link.
Since: 0.1
linkOnly :: (MonadAsync m, HasCallStack) => (SomeException -> Bool) -> Async a -> m () Source #
Lifted linkOnly.
Since: 0.1
link2 :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m () Source #
Lifted link2.
Since: 0.1
link2Only :: (MonadAsync m, HasCallStack) => (SomeException -> Bool) -> Async a -> Async b -> m () Source #
Lifted link2Only.
Since: 0.1
data ExceptionInLinkedThread Source #
Constructors
| ExceptionInLinkedThread (Async a) SomeException |
Instances
| Exception ExceptionInLinkedThread Source # | |
| Show ExceptionInLinkedThread Source # | |
Defined in Control.Concurrent.Async.Internal Methods showsPrec :: Int -> ExceptionInLinkedThread -> ShowS # show :: ExceptionInLinkedThread -> String # showList :: [ExceptionInLinkedThread] -> ShowS # | |
Pooled concurrency
These functions mirror those defined in unliftio.
pooledMapConcurrentlyN Source #
Arguments
| :: (MonadAsync m, HasCallStack, Traversable t) | |
| => Positive Int | . |
| -> (a -> m b) | |
| -> t a | |
| -> m (t b) |
Lifted pooledMapConcurrentlyN.
Since: 0.1
pooledMapConcurrently Source #
Arguments
| :: (MonadAsync m, HasCallStack, Traversable t) | |
| => (a -> m b) | . |
| -> t a | |
| -> m (t b) |
Lifted pooledMapConcurrently.
Since: 0.1
pooledMapConcurrentlyN_ Source #
Arguments
| :: (MonadAsync m, Foldable f, HasCallStack) | |
| => Positive Int | . |
| -> (a -> m b) | |
| -> f a | |
| -> m () |
Lifted pooledMapConcurrentlyN_.
Since: 0.1
pooledMapConcurrently_ Source #
Arguments
| :: (MonadAsync m, Foldable f, HasCallStack) | |
| => (a -> m b) | . |
| -> f a | |
| -> m () |
Lifted pooledMapConcurrently_.
Since: 0.1
pooledForConcurrentlyN Source #
Arguments
| :: (HasCallStack, MonadAsync m, Traversable t) | |
| => Positive Int | Max threads > 0 |
| -> t a | |
| -> (a -> m b) | |
| -> m (t b) |
Lifted pooledForConcurrentlyN.
Since: 0.1
pooledForConcurrently Source #
Arguments
| :: (HasCallStack, MonadAsync m, Traversable t) | |
| => t a | . |
| -> (a -> m b) | |
| -> m (t b) |
Lifted pooledForConcurrently.
Since: 0.1
pooledForConcurrentlyN_ Source #
Arguments
| :: forall m f a b. (Foldable f, HasCallStack, MonadAsync m) | |
| => Positive Int | Max threads > 0 |
| -> f a | |
| -> (a -> m b) | |
| -> m () |
Lifted pooledForConcurrentlyN_.
Since: 0.1
pooledForConcurrently_ Source #
Arguments
| :: forall m f a b. (Foldable f, HasCallStack, MonadAsync m) | |
| => f a | . |
| -> (a -> m b) | |
| -> m () |
Lifted pooledForConcurrently_.
Since: 0.1
pooledReplicateConcurrentlyN Source #
Arguments
| :: (HasCallStack, MonadAsync m) | |
| => Positive Int | Max threads > 0 |
| -> Int | Number of times to perform the action. |
| -> m a | |
| -> m [a] |
Lifted pooledReplicateConcurrentlyN.
Since: 0.1
pooledReplicateConcurrently Source #
Arguments
| :: (HasCallStack, MonadAsync m) | |
| => Positive Int | Number of times to perform the action. |
| -> m a | |
| -> m [a] |
Lifted pooledReplicateConcurrently.
Since: 0.1
pooledReplicateConcurrentlyN_ Source #
Arguments
| :: (HasCallStack, MonadAsync m) | |
| => Positive Int | Max threads > 0 |
| -> Int | Number of times to perform the action. |
| -> m a | |
| -> m () |
Lifted pooledReplicateConcurrentlyN_.
Since: 0.1
pooledReplicateConcurrently_ Source #
Arguments
| :: (HasCallStack, MonadAsync m) | |
| => Int | Number of times to perform the action. |
| -> m a | |
| -> m () |
Lifted pooledReplicateConcurrently_.
Since: 0.1
Reexports
data SomeException #
The SomeException type is the root of the exception type hierarchy.
When an exception of type e is thrown, behind the scenes it is
encapsulated in a SomeException.
Instances
| Exception SomeException # | This drops any attached Since: base-3.0 |
Defined in GHC.Internal.Exception.Type Methods toException :: SomeException -> SomeException # fromException :: SomeException -> Maybe SomeException # displayException :: SomeException -> String # backtraceDesired :: SomeException -> Bool # | |
| Show SomeException # | Since: ghc-internal-3.0 |
Defined in GHC.Internal.Exception.Type Methods showsPrec :: Int -> SomeException -> ShowS # show :: SomeException -> String # showList :: [SomeException] -> ShowS # | |
class Monad m => MonadThread (m :: Type -> Type) Source #
Represents thread effects.
Since: effects-thread-0.1
Minimal complete definition
threadDelay, throwTo, getNumCapabilities, setNumCapabilities, threadCapability, myThreadId, labelThread, threadLabel
Instances
| MonadThread IO Source # | Since: effects-thread-0.1 |
Defined in Effects.Concurrent.Thread Methods threadDelay :: Int -> IO () Source # throwTo :: (Exception e, HasCallStack) => ThreadId -> e -> IO () Source # getNumCapabilities :: IO Int Source # setNumCapabilities :: Int -> IO () Source # threadCapability :: ThreadId -> IO (Int, Bool) Source # myThreadId :: IO ThreadId Source # | |
| MonadThread m => MonadThread (ReaderT e m) Source # | Since: effects-thread-0.1 |
Defined in Effects.Concurrent.Thread Methods threadDelay :: Int -> ReaderT e m () Source # throwTo :: (Exception e0, HasCallStack) => ThreadId -> e0 -> ReaderT e m () Source # getNumCapabilities :: ReaderT e m Int Source # setNumCapabilities :: Int -> ReaderT e m () Source # threadCapability :: ThreadId -> ReaderT e m (Int, Bool) Source # myThreadId :: ReaderT e m ThreadId Source # labelThread :: ThreadId -> String -> ReaderT e m () Source # threadLabel :: ThreadId -> ReaderT e m (Maybe String) Source # | |
Positive
The Positive type comes from
Numeric.Data.Positive
from the
smart-math package. See that module for
more functionality.
data Positive a where Source #
Newtype wrapper that attaches a Positive invariant to some a.
Positive is an ASemigroup and
MGroup i.e. supports addition,
multiplication, and division.
Since: smart-math-0.1
Bundled Patterns
| pattern MkPositive :: a -> Positive a | Unidirectional pattern synonym for Since: smart-math-0.1 |
Instances
| Foldable Positive Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal Methods fold :: Monoid m => Positive m -> m # foldMap :: Monoid m => (a -> m) -> Positive a -> m # foldMap' :: Monoid m => (a -> m) -> Positive a -> m # foldr :: (a -> b -> b) -> b -> Positive a -> b # foldr' :: (a -> b -> b) -> b -> Positive a -> b # foldl :: (b -> a -> b) -> b -> Positive a -> b # foldl' :: (b -> a -> b) -> b -> Positive a -> b # foldr1 :: (a -> a -> a) -> Positive a -> a # foldl1 :: (a -> a -> a) -> Positive a -> a # elem :: Eq a => a -> Positive a -> Bool # maximum :: Ord a => Positive a -> a # minimum :: Ord a => Positive a -> a # | |||||
| HasField "unPositive" (Positive a :: Type) (a :: Type) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal | |||||
| (k ~ A_Getter, x ~ a, y ~ a) => LabelOptic "unPositive" k (Positive a) (Positive a) x y Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal | |||||
| Lift a => Lift (Positive a :: Type) Source # | Since: smart-math-0.1 | ||||
| ASemigroup a => ASemigroup (Positive a) Source # | Since: smart-math-0.1 | ||||
| MetricSpace a => MetricSpace (Positive a) Source # | Since: smart-math-0.1 | ||||
| MEuclidean a => MEuclidean (Positive a) Source # | Since: smart-math-0.1 | ||||
| MGroup a => MGroup (Positive a) Source # | Since: smart-math-0.1 | ||||
| MMonoid a => MMonoid (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal | |||||
| MSemigroup a => MSemigroup (Positive a) Source # | Since: smart-math-0.1 | ||||
| Normed a => Normed (Positive a) Source # | Since: smart-math-0.1 | ||||
| (AMonoid a, FromInteger a, Ord a, Show a) => FromInteger (Positive a) Source # | WARNING: Partial Since: smart-math-0.1 | ||||
| (AMonoid a, FromRational a, Ord a, Show a) => FromRational (Positive a) Source # | WARNING: Partial Since: smart-math-0.1 | ||||
| (AMonoid a, FromReal a, Ord a, Show a) => FromReal (Positive a) Source # | WARNING: Partial Since: smart-math-0.1 | ||||
| ToInteger a => ToInteger (Positive a) Source # | Since: smart-math-0.1 | ||||
| ToRational a => ToRational (Positive a) Source # | Since: smart-math-0.1 | ||||
| ToReal a => ToReal (Positive a) Source # | Since: smart-math-0.1 | ||||
| MaybeLowerBounded (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal Methods maybeLowerBound :: Maybe (Positive a) Source # | |||||
| MaybeUpperBounded a => MaybeUpperBounded (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal Methods maybeUpperBound :: Maybe (Positive a) Source # | |||||
| UpperBounded a => UpperBounded (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal Methods upperBound :: Positive a Source # | |||||
| UpperBoundless (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal | |||||
| NFData a => NFData (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal | |||||
| Generic (Positive a) Source # | |||||
Defined in Numeric.Data.Positive.Internal Associated Types
| |||||
| Show a => Show (Positive a) Source # | Since: smart-math-0.1 | ||||
| Eq a => Eq (Positive a) Source # | Since: smart-math-0.1 | ||||
| Ord a => Ord (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal | |||||
| Hashable a => Hashable (Positive a) Source # | Since: smart-math-0.1 | ||||
| Show a => Display (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal | |||||
| type Rep (Positive a) Source # | Since: smart-math-0.1 | ||||
Defined in Numeric.Data.Positive.Internal type Rep (Positive a) = D1 ('MetaData "Positive" "Numeric.Data.Positive.Internal" "smart-math-0.1-f0c9ff16a3c73c790e424b7a8553f041cb0b35e4c012a8d489c8141e6efe801c" 'True) (C1 ('MetaCons "UnsafePositive" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a))) | |||||
mkPositiveTH :: (AMonoid a, Lift a, Ord a, Show a) => a -> Code Q (Positive a) Source #
Template haskell for creating a Positive at compile-time.
Examples
>>>$$(mkPositiveTH 1)UnsafePositive 1
Since: smart-math-0.1
unsafePositive :: (AMonoid a, HasCallStack, Ord a, Show a) => a -> Positive a Source #
Throws an error when given a value <= 0.
WARNING: Partial
Examples
>>>unsafePositive 7UnsafePositive 7
Since: smart-math-0.1
(+!) :: (AMonoid a, HasCallStack, Ord a, Show a) => a -> Positive a infixl 7 Source #
Postfix operator for unsafePositive.
WARNING: Partial
Examples
>>>(7 +!)UnsafePositive 7
Since: smart-math-0.1