effects-async-0.1: Async effects
Safe HaskellNone
LanguageGHC2021

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

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

withAsyncWithUnmask Source #

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

waitAnyCatch Source #

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

waitAnyCatchCancel Source #

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

waitEitherCatch Source #

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

Instances details
MonadAsync IO Source #

Since: 0.1

Instance details

Defined in Effects.Concurrent.Async

Methods

withAsync :: HasCallStack => IO a -> (Async a -> IO b) -> IO b Source #

withAsyncBound :: HasCallStack => IO a -> (Async a -> IO b) -> IO b Source #

withAsyncOn :: HasCallStack => Int -> IO a -> (Async a -> IO b) -> IO b Source #

withAsyncWithUnmask :: HasCallStack => ((forall c. IO c -> IO c) -> IO a) -> (Async a -> IO b) -> IO b Source #

withAsyncOnWithUnmask :: HasCallStack => Int -> ((forall c. IO c -> IO c) -> IO a) -> (Async a -> IO b) -> IO b Source #

wait :: HasCallStack => Async a -> IO a Source #

poll :: HasCallStack => Async a -> IO (Maybe (Either SomeException a)) Source #

waitCatch :: HasCallStack => Async a -> IO (Either SomeException a) Source #

cancel :: HasCallStack => Async a -> IO () Source #

uninterruptibleCancel :: HasCallStack => Async a -> IO () Source #

cancelWith :: (Exception e, HasCallStack) => Async a -> e -> IO () Source #

race :: HasCallStack => IO a -> IO b -> IO (Either a b) Source #

concurrently :: HasCallStack => IO a -> IO b -> IO (a, b) Source #

concurrently_ :: HasCallStack => IO a -> IO b -> IO () Source #

waitAny :: HasCallStack => [Async a] -> IO (Async a, a) Source #

waitAnyCatch :: HasCallStack => [Async a] -> IO (Async a, Either SomeException a) Source #

waitAnyCancel :: HasCallStack => [Async a] -> IO (Async a, a) Source #

waitAnyCatchCancel :: HasCallStack => [Async a] -> IO (Async a, Either SomeException a) Source #

waitEither :: HasCallStack => Async a -> Async b -> IO (Either a b) Source #

waitEitherCatch :: HasCallStack => Async a -> Async b -> IO (Either (Either SomeException a) (Either SomeException b)) Source #

waitEitherCancel :: HasCallStack => Async a -> Async b -> IO (Either a b) Source #

waitEitherCatchCancel :: HasCallStack => Async a -> Async b -> IO (Either (Either SomeException a) (Either SomeException b)) Source #

waitEither_ :: HasCallStack => Async a -> Async b -> IO () Source #

waitBoth :: HasCallStack => Async a -> Async b -> IO (a, b) Source #

async :: HasCallStack => IO a -> IO (Async a) Source #

asyncBound :: HasCallStack => IO a -> IO (Async a) Source #

asyncOn :: HasCallStack => Int -> IO a -> IO (Async a) Source #

asyncWithUnmask :: HasCallStack => ((forall b. IO b -> IO b) -> IO a) -> IO (Async a) Source #

asyncOnWithUnmask :: HasCallStack => Int -> ((forall b. IO b -> IO b) -> IO a) -> IO (Async a) Source #

link :: HasCallStack => Async a -> IO () Source #

linkOnly :: HasCallStack => (SomeException -> Bool) -> Async a -> IO () Source #

link2 :: HasCallStack => Async a -> Async b -> IO () Source #

link2Only :: HasCallStack => (SomeException -> Bool) -> Async a -> Async b -> IO () Source #

pooledMapConcurrentlyN :: (HasCallStack, Traversable t) => Positive Int -> (a -> IO b) -> t a -> IO (t b) Source #

pooledMapConcurrently :: (HasCallStack, Traversable t) => (a -> IO b) -> t a -> IO (t b) Source #

pooledMapConcurrentlyN_ :: (Foldable f, HasCallStack) => Positive Int -> (a -> IO b) -> f a -> IO () Source #

pooledMapConcurrently_ :: (Foldable f, HasCallStack) => (a -> IO b) -> f a -> IO () Source #

MonadAsync m => MonadAsync (ReaderT env m) Source #

Since: 0.1

Instance details

Defined in Effects.Concurrent.Async

Methods

withAsync :: HasCallStack => ReaderT env m a -> (Async a -> ReaderT env m b) -> ReaderT env m b Source #

withAsyncBound :: HasCallStack => ReaderT env m a -> (Async a -> ReaderT env m b) -> ReaderT env m b Source #

withAsyncOn :: HasCallStack => Int -> ReaderT env m a -> (Async a -> ReaderT env m b) -> ReaderT env m b Source #

withAsyncWithUnmask :: HasCallStack => ((forall c. ReaderT env m c -> ReaderT env m c) -> ReaderT env m a) -> (Async a -> ReaderT env m b) -> ReaderT env m b Source #

withAsyncOnWithUnmask :: HasCallStack => Int -> ((forall c. ReaderT env m c -> ReaderT env m c) -> ReaderT env m a) -> (Async a -> ReaderT env m b) -> ReaderT env m b Source #

wait :: HasCallStack => Async a -> ReaderT env m a Source #

poll :: HasCallStack => Async a -> ReaderT env m (Maybe (Either SomeException a)) Source #

waitCatch :: HasCallStack => Async a -> ReaderT env m (Either SomeException a) Source #

cancel :: HasCallStack => Async a -> ReaderT env m () Source #

uninterruptibleCancel :: HasCallStack => Async a -> ReaderT env m () Source #

cancelWith :: (Exception e, HasCallStack) => Async a -> e -> ReaderT env m () Source #

race :: HasCallStack => ReaderT env m a -> ReaderT env m b -> ReaderT env m (Either a b) Source #

concurrently :: HasCallStack => ReaderT env m a -> ReaderT env m b -> ReaderT env m (a, b) Source #

concurrently_ :: HasCallStack => ReaderT env m a -> ReaderT env m b -> ReaderT env m () Source #

waitAny :: HasCallStack => [Async a] -> ReaderT env m (Async a, a) Source #

waitAnyCatch :: HasCallStack => [Async a] -> ReaderT env m (Async a, Either SomeException a) Source #

waitAnyCancel :: HasCallStack => [Async a] -> ReaderT env m (Async a, a) Source #

waitAnyCatchCancel :: HasCallStack => [Async a] -> ReaderT env m (Async a, Either SomeException a) Source #

waitEither :: HasCallStack => Async a -> Async b -> ReaderT env m (Either a b) Source #

waitEitherCatch :: HasCallStack => Async a -> Async b -> ReaderT env m (Either (Either SomeException a) (Either SomeException b)) Source #

waitEitherCancel :: HasCallStack => Async a -> Async b -> ReaderT env m (Either a b) Source #

waitEitherCatchCancel :: HasCallStack => Async a -> Async b -> ReaderT env m (Either (Either SomeException a) (Either SomeException b)) Source #

waitEither_ :: HasCallStack => Async a -> Async b -> ReaderT env m () Source #

waitBoth :: HasCallStack => Async a -> Async b -> ReaderT env m (a, b) Source #

async :: HasCallStack => ReaderT env m a -> ReaderT env m (Async a) Source #

asyncBound :: HasCallStack => ReaderT env m a -> ReaderT env m (Async a) Source #

asyncOn :: HasCallStack => Int -> ReaderT env m a -> ReaderT env m (Async a) Source #

asyncWithUnmask :: HasCallStack => ((forall b. ReaderT env m b -> ReaderT env m b) -> ReaderT env m a) -> ReaderT env m (Async a) Source #

asyncOnWithUnmask :: HasCallStack => Int -> ((forall b. ReaderT env m b -> ReaderT env m b) -> ReaderT env m a) -> ReaderT env m (Async a) Source #

link :: HasCallStack => Async a -> ReaderT env m () Source #

linkOnly :: HasCallStack => (SomeException -> Bool) -> Async a -> ReaderT env m () Source #

link2 :: HasCallStack => Async a -> Async b -> ReaderT env m () Source #

link2Only :: HasCallStack => (SomeException -> Bool) -> Async a -> Async b -> ReaderT env m () Source #

pooledMapConcurrentlyN :: (HasCallStack, Traversable t) => Positive Int -> (a -> ReaderT env m b) -> t a -> ReaderT env m (t b) Source #

pooledMapConcurrently :: (HasCallStack, Traversable t) => (a -> ReaderT env m b) -> t a -> ReaderT env m (t b) Source #

pooledMapConcurrentlyN_ :: (Foldable f, HasCallStack) => Positive Int -> (a -> ReaderT env m b) -> f a -> ReaderT env m () Source #

pooledMapConcurrently_ :: (Foldable f, HasCallStack) => (a -> ReaderT env m b) -> f a -> ReaderT env m () Source #

Asynchronous Actions

data Async a Source #

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).

Instances

Instances details
Functor Async 
Instance details

Defined in Control.Concurrent.Async.Internal

Methods

fmap :: (a -> b) -> Async a -> Async b #

(<$) :: a -> Async b -> Async a #

Eq (Async a) 
Instance details

Defined in Control.Concurrent.Async.Internal

Methods

(==) :: Async a -> Async a -> Bool #

(/=) :: Async a -> Async a -> Bool #

Ord (Async a) 
Instance details

Defined in Control.Concurrent.Async.Internal

Methods

compare :: Async a -> Async a -> Ordering #

(<) :: Async a -> Async a -> Bool #

(<=) :: Async a -> Async a -> Bool #

(>) :: Async a -> Async a -> Bool #

(>=) :: Async a -> Async a -> Bool #

max :: Async a -> Async a -> Async a #

min :: Async a -> Async a -> Async a #

Hashable (Async a) 
Instance details

Defined in Control.Concurrent.Async.Internal

Methods

hashWithSalt :: Int -> Async a -> Int Source #

hash :: Async a -> Int Source #

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

withAsyncWithUnmask Source #

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

asyncThreadId :: Async a -> ThreadId Source #

Returns the ThreadId of the thread running the given Async.

cancel :: (MonadAsync m, HasCallStack) => Async a -> m () Source #

Lifted cancel.

Since: 0.1

cancelWith :: (MonadAsync m, Exception e, HasCallStack) => Async a -> e -> m () Source #

Lifted cancelWith.

Since: 0.1

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

mapConcurrently Source #

Arguments

:: (MonadAsync m, Traversable t) 
=> (a -> m b)

.

-> t a 
-> m (t b) 

Lifted mapConcurrently.

Since: 0.1

forConcurrently Source #

Arguments

:: (MonadAsync m, Traversable t) 
=> t a

.

-> (a -> m b) 
-> m (t b) 

Lifted forConcurrently.

Since: 0.1

mapConcurrently_ Source #

Arguments

:: (MonadAsync m, Foldable f) 
=> (a -> m b)

.

-> f a 
-> m () 

Lifted mapConcurrently_.

Since: 0.1

forConcurrently_ Source #

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

Instances details
(MonadAsync m, MonadThread m) => Alternative (Concurrently m) Source #

Since: 0.1

Instance details

Defined in Effects.Concurrent.Async

Methods

empty :: Concurrently m a #

(<|>) :: Concurrently m a -> Concurrently m a -> Concurrently m a #

some :: Concurrently m a -> Concurrently m [a] #

many :: Concurrently m a -> Concurrently m [a] #

MonadAsync m => Applicative (Concurrently m) Source #

Since: 0.1

Instance details

Defined in Effects.Concurrent.Async

Methods

pure :: a -> Concurrently m a #

(<*>) :: Concurrently m (a -> b) -> Concurrently m a -> Concurrently m b #

liftA2 :: (a -> b -> c) -> Concurrently m a -> Concurrently m b -> Concurrently m c #

(*>) :: Concurrently m a -> Concurrently m b -> Concurrently m b #

(<*) :: Concurrently m a -> Concurrently m b -> Concurrently m a #

Functor m => Functor (Concurrently m) Source #

Since: 0.1

Instance details

Defined in Effects.Concurrent.Async

Methods

fmap :: (a -> b) -> Concurrently m a -> Concurrently m b #

(<$) :: a -> Concurrently m b -> Concurrently m a #

(MonadAsync m, Monoid a) => Monoid (Concurrently m a) Source #

Since: 0.1

Instance details

Defined in Effects.Concurrent.Async

(MonadAsync m, Semigroup a) => Semigroup (Concurrently m a) Source #

Since: 0.1

Instance details

Defined in Effects.Concurrent.Async

Methods

(<>) :: Concurrently m a -> Concurrently m a -> Concurrently m a #

sconcat :: NonEmpty (Concurrently m a) -> Concurrently m a #

stimes :: Integral b => b -> Concurrently m a -> Concurrently m a #

compareAsyncs :: Async a -> Async b -> Ordering Source #

Compare two Asyncs that may have different types by their ThreadId.

Specialised operations

STM Operations

data STM a #

A monad supporting atomic memory transactions.

Instances

Instances details
Alternative STM

Takes the first non-retrying STM action.

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

empty :: STM a #

(<|>) :: STM a -> STM a -> STM a #

some :: STM a -> STM [a] #

many :: STM a -> STM [a] #

Applicative STM

Since: base-4.8.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

pure :: a -> STM a #

(<*>) :: STM (a -> b) -> STM a -> STM b #

liftA2 :: (a -> b -> c) -> STM a -> STM b -> STM c #

(*>) :: STM a -> STM b -> STM b #

(<*) :: STM a -> STM b -> STM a #

Functor STM

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

fmap :: (a -> b) -> STM a -> STM b #

(<$) :: a -> STM b -> STM a #

Monad STM

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

(>>=) :: STM a -> (a -> STM b) -> STM b #

(>>) :: STM a -> STM b -> STM b #

return :: a -> STM a #

MonadPlus STM

Takes the first non-retrying STM action.

Since: base-4.3.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

mzero :: STM a #

mplus :: STM a -> STM a -> STM a #

MonadCatch STM 
Instance details

Defined in Control.Monad.Catch

Methods

catch :: (HasCallStack, Exception e) => STM a -> (e -> STM a) -> STM a #

MonadThrow STM 
Instance details

Defined in Control.Monad.Catch

Methods

throwM :: (HasCallStack, Exception e) => e -> STM a #

Monoid a => Monoid (STM a)

Since: base-4.17.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

mempty :: STM a #

mappend :: STM a -> STM a -> STM a #

mconcat :: [STM a] -> STM a #

Semigroup a => Semigroup (STM a)

Since: base-4.17.0.0

Instance details

Defined in GHC.Conc.Sync

Methods

(<>) :: STM a -> STM a -> STM a #

sconcat :: NonEmpty (STM a) -> STM a #

stimes :: Integral b => b -> STM a -> STM a #

waitSTM :: Async a -> STM a Source #

A version of wait that can be used inside an STM transaction.

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

waitAnyCatch Source #

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

waitAnyCatchCancel Source #

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

waitEitherCancel :: (MonadAsync m, HasCallStack) => Async a -> Async b -> m (Either a b) Source #

Lifted waitEitherCancel.

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

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] 

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 () 

pooledReplicateConcurrently_ Source #

Arguments

:: (HasCallStack, MonadAsync m) 
=> Int

Number of times to perform the action.

-> m a 
-> m () 

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

Instances details
Exception SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception.Type

Show SomeException

Since: base-3.0

Instance details

Defined in GHC.Exception.Type

class Monad m => MonadThread (m :: Type -> Type) Source #

Represents thread effects.

Since: effects-thread-0.1

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 Positive. This allows us to pattern match on a positive term without exposing the unsafe internal details.

Since: smart-math-0.1

Instances

Instances details
HasField "unPositive" (Positive a) a

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

getField :: Positive a -> a #

(k ~ A_Getter, x ~ a, y ~ a) => LabelOptic "unPositive" k (Positive a) (Positive a) x y

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

labelOptic :: Optic k NoIx (Positive a) (Positive a) x y Source #

Lift a => Lift (Positive a :: Type)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

lift :: Quote m => Positive a -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Positive a -> Code m (Positive a) #

Num a => ASemigroup (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

(.+.) :: Positive a -> Positive a -> Positive a Source #

(Division a, Integral a) => MEuclidean (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

mdivMod :: Positive a -> Positive a -> (Positive a, Positive a) Source #

(Division a, Num a) => MGroup (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

(.%.) :: Positive a -> Positive a -> Positive a Source #

Num a => MMonoid (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

one :: Positive a Source #

Num a => MSemigroup (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

(.*.) :: Positive a -> Positive a -> Positive a Source #

Normed (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

norm :: Positive a -> Positive a Source #

(Num a, Ord a, Show a) => FromInteger (Positive a)

WARNING: Partial

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

(Fractional a, Ord a, Show a) => FromRational (Positive a)

WARNING: Partial

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Generic (Positive a) 
Instance details

Defined in Numeric.Data.Positive.Internal

Associated Types

type Rep (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

type Rep (Positive a) = D1 ('MetaData "Positive" "Numeric.Data.Positive.Internal" "smart-math-0.1-0b95315b21a6a69ebe988e96f62c8ea75d6158da2cb659ceca194755f22ca28b" 'True) (C1 ('MetaCons "UnsafePositive" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: Positive a -> Rep (Positive a) x #

to :: Rep (Positive a) x -> Positive a #

Show a => Show (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

showsPrec :: Int -> Positive a -> ShowS #

show :: Positive a -> String #

showList :: [Positive a] -> ShowS #

Bounded a => UpperBounded (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

UpperBoundless (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

NFData a => NFData (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

rnf :: Positive a -> () #

Eq a => Eq (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

(==) :: Positive a -> Positive a -> Bool #

(/=) :: Positive a -> Positive a -> Bool #

Ord a => Ord (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

compare :: Positive a -> Positive a -> Ordering #

(<) :: Positive a -> Positive a -> Bool #

(<=) :: Positive a -> Positive a -> Bool #

(>) :: Positive a -> Positive a -> Bool #

(>=) :: Positive a -> Positive a -> Bool #

max :: Positive a -> Positive a -> Positive a #

min :: Positive a -> Positive a -> Positive a #

Show a => Display (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

type Rep (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

type Rep (Positive a) = D1 ('MetaData "Positive" "Numeric.Data.Positive.Internal" "smart-math-0.1-0b95315b21a6a69ebe988e96f62c8ea75d6158da2cb659ceca194755f22ca28b" 'True) (C1 ('MetaCons "UnsafePositive" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

mkPositive :: (Num a, Ord a) => a -> Maybe (Positive a) Source #

Smart constructor for Positive. Returns Nothing if the second parameter is <= 0.

Examples

Expand
>>> mkPositive 7
Just (UnsafePositive 7)
>>> mkPositive 0
Nothing

Since: smart-math-0.1

mkPositiveTH :: (Integral a, Lift a, Show a) => a -> Code Q (Positive a) Source #

Template haskell for creating a Positive at compile-time.

Examples

Expand
>>> $$(mkPositiveTH 1)
UnsafePositive 1

Since: smart-math-0.1

unsafePositive :: (HasCallStack, Num a, Ord a, Show a) => a -> Positive a Source #

Throws an error when given a value <= 0.

WARNING: Partial

Examples

Expand
>>> unsafePositive 7
UnsafePositive 7

Since: smart-math-0.1

(+!) :: (HasCallStack, Num a, Ord a, Show a) => a -> Positive a infixl 7 Source #

Postfix operator for unsafePositive.

WARNING: Partial

Examples

Expand
>>> (7 +!)
UnsafePositive 7

Since: smart-math-0.1