Safe Haskell | None |
---|---|
Language | Haskell2010 |
Interface adapted from Control.Concurrent.Async
Synopsis
- data Conc m a
- data Async a
- concToIO :: (Carrier m, MonadBaseControlPure IO m) => ConcToIOC m a -> m a
- concToUnliftIO :: Eff (Unlift IO) m => ConcToUnliftIOC m a -> m a
- async :: Eff Conc m => m a -> m (Async a)
- withAsync :: Eff Conc m => m a -> (Async a -> m b) -> m b
- wait :: Eff Conc m => Async a -> m a
- poll :: Eff Conc m => Async a -> m (Maybe (Either SomeException a))
- concurrently :: Eff Conc m => m a -> m b -> m (a, b)
- race :: Eff Conc m => m a -> m b -> m (Either a b)
- waitEither :: Eff Conc m => Async a -> Async b -> m (Either a b)
- waitBoth :: Eff Conc m => Async a -> Async b -> m (a, b)
- link :: Eff Conc m => Async a -> m ()
- link2 :: Eff Conc m => Async a -> Async b -> m ()
- waitAny :: Eff Conc m => [Async a] -> m (Async a, a)
- mapConcurrently :: (Traversable t, Eff Conc m) => (a -> m b) -> t a -> m (t b)
- forConcurrently :: (Traversable t, Eff Conc m) => t a -> (a -> m b) -> m (t b)
- newtype Concurrently m a = Concurrently {
- runConcurrently :: m a
- asyncBound :: Eff Conc m => m a -> m (Async a)
- asyncOn :: Eff Conc m => Int -> m a -> m (Async a)
- asyncWithUnmask :: Eff Conc m => ((forall x. m x -> m x) -> m a) -> m (Async a)
- asyncOnWithUnmask :: Eff Conc m => Int -> ((forall x. m x -> m x) -> m a) -> m (Async a)
- withAsyncBound :: Eff Conc m => m a -> (Async a -> m b) -> m b
- withAsyncWithUnmask :: Eff Conc m => ((forall x. m x -> m x) -> m a) -> (Async a -> m b) -> m b
- withAsyncOnWithUnmask :: Eff Conc m => Int -> ((forall x. m x -> m x) -> m a) -> (Async a -> m b) -> m b
- waitCatch :: Eff Conc m => Async a -> m (Either SomeException a)
- cancel :: Eff Conc m => Async a -> m ()
- uninterruptibleCancel :: Eff Conc m => Async a -> m ()
- cancelWith :: Eff Conc m => (Exception e, Eff Conc m) => Async a -> e -> m ()
- waitAnyCatch :: Eff Conc m => [Async a] -> m (Async a, Either SomeException a)
- waitAnyCancel :: Eff Conc m => [Async a] -> m (Async a, a)
- waitAnyCatchCancel :: Eff Conc m => [Async a] -> m (Async a, Either SomeException a)
- waitEitherCatch :: Eff Conc m => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))
- waitEitherCancel :: Eff Conc m => Async a -> Async b -> m (Either a b)
- waitEitherCatchCancel :: Eff Conc m => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b))
- waitEither_ :: Eff Conc m => Async a -> Async b -> m ()
- linkOnly :: Eff Conc m => (SomeException -> Bool) -> Async a -> m ()
- link2Only :: Eff Conc m => (SomeException -> Bool) -> Async a -> Async b -> m ()
- race_ :: Eff Conc m => m a -> m b -> m ()
- concurrently_ :: Eff Conc m => m a -> m b -> m ()
- mapConcurrently_ :: (Foldable t, Eff Conc m) => (a -> m b) -> t a -> m ()
- forConcurrently_ :: (Foldable t, Eff Conc m) => t a -> (a -> m b) -> m ()
- replicateConcurrently :: Eff Conc m => Int -> m a -> m [a]
- replicateConcurrently_ :: Eff Conc m => Int -> m a -> m ()
- asyncThreadId :: Async a -> ThreadId
- data AsyncCancelled = AsyncCancelled
- data ExceptionInLinkedThread where
- ExceptionInLinkedThread :: forall a. Async a -> SomeException -> ExceptionInLinkedThread
- 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)
- compareAsyncs :: Async a -> Async b -> Ordering
- type ConcToIOC = CompositionC '[UnwrapTopC Conc, UnliftToFinalC IO]
- type ConcToUnliftIOC = UnwrapC Conc
Effects
An effect for concurrent execution.
Instances
EffNewtype Conc Source # | |
Defined in Control.Effect.Conc type UnwrappedEff Conc :: Effect Source # | |
type UnwrappedEff Conc Source # | |
Defined in Control.Effect.Conc |
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
).
Interpretations
concToIO :: (Carrier m, MonadBaseControlPure IO m) => ConcToIOC m a -> m a Source #
Run a Conc
effect if all effects used in the program --
past and future -- are eventually reduced to operations on IO
.
Due to its very restrictive primitive effect and carrier constraint,
concToIO
can't be used together with most pure interpreters.
For example, instead of runError
, you must use
errorToIO
.
This poses a problem if you want to use some effect that doesn't have
an interpreter compatible with concToIO
-- like
NonDet
.
In that case, you might sitll be able to use both effects in the same program
by applying
/Split Interpretation/
to seperate their uses.
Derivs
(ConcToIOC
m) =Conc
':Derivs
m
Prims
(ConcToIOC
m) =Unlift
IO
':Prims
m
concToUnliftIO :: Eff (Unlift IO) m => ConcToUnliftIOC m a -> m a Source #
Key actions
concurrently :: Eff Conc m => m a -> m b -> m (a, b) Source #
mapConcurrently :: (Traversable t, Eff Conc m) => (a -> m b) -> t a -> m (t b) Source #
forConcurrently :: (Traversable t, Eff Conc m) => t a -> (a -> m b) -> m (t b) Source #
Concurrently applicative
newtype Concurrently m a Source #
Concurrently | |
|
Instances
Other actions
withAsyncWithUnmask :: Eff Conc m => ((forall x. m x -> m x) -> m a) -> (Async a -> m b) -> m b Source #
withAsyncOnWithUnmask :: Eff Conc m => Int -> ((forall x. m x -> m x) -> m a) -> (Async a -> m b) -> m b Source #
waitAnyCatch :: Eff Conc m => [Async a] -> m (Async a, Either SomeException a) Source #
waitAnyCatchCancel :: Eff Conc m => [Async a] -> m (Async a, Either SomeException a) Source #
waitEitherCatch :: Eff Conc m => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b)) Source #
waitEitherCatchCancel :: Eff Conc m => Async a -> Async b -> m (Either (Either SomeException a) (Either SomeException b)) Source #
concurrently_ :: Eff Conc m => m a -> m b -> m () Source #
Re-exports from Control.Concurrent.Async
data AsyncCancelled #
The exception thrown by cancel
to terminate a thread.
Instances
Eq AsyncCancelled | |
Defined in Control.Concurrent.Async (==) :: AsyncCancelled -> AsyncCancelled -> Bool # (/=) :: AsyncCancelled -> AsyncCancelled -> Bool # | |
Show AsyncCancelled | |
Defined in Control.Concurrent.Async showsPrec :: Int -> AsyncCancelled -> ShowS # show :: AsyncCancelled -> String # showList :: [AsyncCancelled] -> ShowS # | |
Exception AsyncCancelled | |
Defined in Control.Concurrent.Async |
data ExceptionInLinkedThread where #
ExceptionInLinkedThread :: forall a. Async a -> SomeException -> ExceptionInLinkedThread |
Instances
Show ExceptionInLinkedThread | |
Defined in Control.Concurrent.Async showsPrec :: Int -> ExceptionInLinkedThread -> ShowS # show :: ExceptionInLinkedThread -> String # showList :: [ExceptionInLinkedThread] -> ShowS # | |
Exception ExceptionInLinkedThread | |
waitAnySTM :: [Async a] -> STM (Async a, a) #
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) #
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) #
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)) #
A version of waitEitherCatch
that can be used inside an STM transaction.
Since: async-2.1.0
waitEitherSTM_ :: Async a -> Async b -> STM () #
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) #
A version of waitBoth
that can be used inside an STM transaction.
Since: async-2.1.0
compareAsyncs :: Async a -> Async b -> Ordering #
Compare two Asyncs that may have different types by their ThreadId.
Carriers
type ConcToIOC = CompositionC '[UnwrapTopC Conc, UnliftToFinalC IO] Source #
type ConcToUnliftIOC = UnwrapC Conc Source #