Copyright | (c) 2024 Sayo Koyoneda |
---|---|
License | MPL-2.0 (see the file LICENSE) |
Maintainer | [email protected] |
Safe Haskell | None |
Language | GHC2021 |
Data.Effect.Concurrent.Parallel
Description
Effects for parallel computations.
Synopsis
- data Parallel (f :: Type -> Type) a where
- data Halt a where
- data Race (f :: Type -> Type) a where
- type LHalt = LiftFOE Halt
- pattern LHalt :: forall a f a1. () => forall. (a ~ a1, ()) => LiftFOE Halt f a
- halt :: forall a f. SendFOE Halt f => f a
- halt' :: forall {k} (tag :: k) a f. SendFOE (Tag Halt tag) f => f a
- halt'' :: forall {k} (key :: k) a f. SendFOEBy key Halt f => f a
- liftP2 :: forall a b c f. SendHOE Parallel f => (a -> b -> c) -> f a -> f b -> f c
- liftP2' :: forall {k} (tag :: k) a b c f. SendHOE (TagH Parallel tag) f => (a -> b -> c) -> f a -> f b -> f c
- liftP2'' :: forall {k} (key :: k) a b c f. SendHOEBy key Parallel f => (a -> b -> c) -> f a -> f b -> f c
- race :: forall a f. SendHOE Race f => f a -> f a -> f a
- race' :: forall {k} (tag :: k) a f. SendHOE (TagH Race tag) f => f a -> f a -> f a
- race'' :: forall {k} (key :: k) a f. SendHOEBy key Race f => f a -> f a -> f a
- newtype Concurrently (f :: k -> Type) (a :: k) = Concurrently {
- runConcurrently :: f a
- liftP3 :: (Parallel <<: f, Applicative f) => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- data Poll (f :: Type -> Type) a where
- poldl :: forall a b r f. SendHOE Poll f => (a -> Maybe b -> f (Either r a)) -> f a -> f b -> f r
- poldl' :: forall {k} (tag :: k) a b r f. SendHOE (TagH Poll tag) f => (a -> Maybe b -> f (Either r a)) -> f a -> f b -> f r
- poldl'' :: forall {k} (key :: k) a b r f. SendHOEBy key Poll f => (a -> Maybe b -> f (Either r a)) -> f a -> f b -> f r
- cancels :: (Poll <<: f, Applicative f) => f a -> f b -> f (a, Maybe b)
- cancelBy :: (Poll <<: f, Applicative f) => f a -> f b -> f (Maybe a, b)
- data For (t :: Type -> Type) (f :: Type -> Type) a where
- for :: forall t a f. SendHOE (For t) f => t (f a) -> f (t a)
- for' :: forall {k} (tag :: k) t a f. SendHOE (TagH (For t) tag) f => t (f a) -> f (t a)
- for'' :: forall {k} (key :: k) t a f. SendHOEBy key (For t) f => t (f a) -> f (t a)
- forToParallel :: forall (f :: Type -> Type) (t :: Type -> Type). (Parallel <<: f, Traversable t, Applicative f) => For t f ~> f
Documentation
data Parallel (f :: Type -> Type) a where Source #
An Applicative
-based effect for executing computations in parallel.
Constructors
LiftP2 | Executes two actions in parallel and blocks until both are complete. Finally, aggregates the execution results based on the specified function. |
An effect that blocks a computation indefinitely.
data Race (f :: Type -> Type) a where Source #
An effect that adopts the result of the computation that finishes first among two computations and cancels the other.
halt' :: forall {k} (tag :: k) a f. SendFOE (Tag Halt tag) f => f a Source #
Blocks a computation indefinitely.
halt'' :: forall {k} (key :: k) a f. SendFOEBy key Halt f => f a Source #
Blocks a computation indefinitely.
Arguments
:: forall a b c f. SendHOE Parallel f | |
=> (a -> b -> c) | |
-> f a | |
-> f b | The second action to be executed in parallel. |
-> f c |
Executes two actions in parallel and blocks until both are complete. Finally, aggregates the execution results based on the specified function.
Arguments
:: forall {k} (tag :: k) a b c f. SendHOE (TagH Parallel tag) f | |
=> (a -> b -> c) | |
-> f a | |
-> f b | The second action to be executed in parallel. |
-> f c |
Executes two actions in parallel and blocks until both are complete. Finally, aggregates the execution results based on the specified function.
Arguments
:: forall {k} (key :: k) a b c f. SendHOEBy key Parallel f | |
=> (a -> b -> c) | |
-> f a | |
-> f b | The second action to be executed in parallel. |
-> f c |
Executes two actions in parallel and blocks until both are complete. Finally, aggregates the execution results based on the specified function.
race :: forall a f. SendHOE Race f => f a -> f a -> f a Source #
Adopts the result of the computation that finishes first among two computations and cancels the other.
race' :: forall {k} (tag :: k) a f. SendHOE (TagH Race tag) f => f a -> f a -> f a Source #
Adopts the result of the computation that finishes first among two computations and cancels the other.
race'' :: forall {k} (key :: k) a f. SendHOEBy key Race f => f a -> f a -> f a Source #
Adopts the result of the computation that finishes first among two computations and cancels the other.
newtype Concurrently (f :: k -> Type) (a :: k) Source #
A wrapper that allows using the Parallel
effect in the form of Applicative
/
Alternative
instances.
Constructors
Concurrently | |
Fields
|
Instances
(Race <<: f, Halt <: f, Parallel <<: f, Applicative f) => Alternative (Concurrently f) Source # | |
Defined in Data.Effect.Concurrent.Parallel Methods empty :: Concurrently f a # (<|>) :: Concurrently f a -> Concurrently f a -> Concurrently f a # some :: Concurrently f a -> Concurrently f [a] # many :: Concurrently f a -> Concurrently f [a] # | |
(Parallel <<: f, Applicative f) => Applicative (Concurrently f) Source # | |
Defined in Data.Effect.Concurrent.Parallel Methods pure :: a -> Concurrently f a # (<*>) :: Concurrently f (a -> b) -> Concurrently f a -> Concurrently f b # liftA2 :: (a -> b -> c) -> Concurrently f a -> Concurrently f b -> Concurrently f c # (*>) :: Concurrently f a -> Concurrently f b -> Concurrently f b # (<*) :: Concurrently f a -> Concurrently f b -> Concurrently f a # | |
Functor f => Functor (Concurrently f) Source # | |
Defined in Data.Effect.Concurrent.Parallel Methods fmap :: (a -> b) -> Concurrently f a -> Concurrently f b # (<$) :: a -> Concurrently f b -> Concurrently f a # |
Arguments
:: (Parallel <<: f, Applicative f) | |
=> (a -> b -> c -> d) | A function that aggregates the three execution results. |
-> f a | The first action to be executed in parallel. |
-> f b | The second action to be executed in parallel. |
-> f c | The third action to be executed in parallel. |
-> f d |
Executes three actions in parallel and blocks until all are complete. Finally, aggregates the execution results based on the specified function.
data Poll (f :: Type -> Type) a where Source #
An effect that realizes polling and cancellation of actions running in parallel.
Constructors
Poldl | Performs polling on an action running in parallel in the form of a fold. First, the parallel execution of two actions begins. When the execution of the first action completes, polling on the second
action is performed at that point, and the result is passed to the
folding function. If the function returns |
Arguments
:: forall a b r f. SendHOE Poll f | |
=> (a -> Maybe b -> f (Either r a)) | |
-> f a | |
-> f b | The second action to be executed in parallel; the target of polling. |
-> f r |
Performs polling on an action running in parallel in the form of a fold.
First, the parallel execution of two actions begins.
When the execution of the first action completes, polling on the second
action is performed at that point, and the result is passed to the
folding function. If the function returns Left
, the folding terminates
and it becomes the final result. If the second action is not yet
complete, it is canceled. If the function returns Right
, the folding
continues, and the same process repeats.
Arguments
:: forall {k} (tag :: k) a b r f. SendHOE (TagH Poll tag) f | |
=> (a -> Maybe b -> f (Either r a)) | |
-> f a | |
-> f b | The second action to be executed in parallel; the target of polling. |
-> f r |
Performs polling on an action running in parallel in the form of a fold.
First, the parallel execution of two actions begins.
When the execution of the first action completes, polling on the second
action is performed at that point, and the result is passed to the
folding function. If the function returns Left
, the folding terminates
and it becomes the final result. If the second action is not yet
complete, it is canceled. If the function returns Right
, the folding
continues, and the same process repeats.
Arguments
:: forall {k} (key :: k) a b r f. SendHOEBy key Poll f | |
=> (a -> Maybe b -> f (Either r a)) | |
-> f a | |
-> f b | The second action to be executed in parallel; the target of polling. |
-> f r |
Performs polling on an action running in parallel in the form of a fold.
First, the parallel execution of two actions begins.
When the execution of the first action completes, polling on the second
action is performed at that point, and the result is passed to the
folding function. If the function returns Left
, the folding terminates
and it becomes the final result. If the second action is not yet
complete, it is canceled. If the function returns Right
, the folding
continues, and the same process repeats.
Arguments
:: (Poll <<: f, Applicative f) | |
=> f a | The action that controls the cancellation. |
-> f b | The action to be canceled. |
-> f (a, Maybe b) |
Executes two actions in parallel. If the first action completes before the second, the second action is canceled.
Arguments
:: (Poll <<: f, Applicative f) | |
=> f a | The action to be canceled. |
-> f b | The action that controls the cancellation. |
-> f (Maybe a, b) |
Executes two actions in parallel. If the second action completes before the first, the first action is canceled.
data For (t :: Type -> Type) (f :: Type -> Type) a where Source #
An effect for parallel computations based on a Traversable
container t
.
for :: forall t a f. SendHOE (For t) f => t (f a) -> f (t a) Source #
Executes in parallel the actions stored within a Traversable
container t
.
for' :: forall {k} (tag :: k) t a f. SendHOE (TagH (For t) tag) f => t (f a) -> f (t a) Source #
Executes in parallel the actions stored within a Traversable
container t
.
for'' :: forall {k} (key :: k) t a f. SendHOEBy key (For t) f => t (f a) -> f (t a) Source #
Executes in parallel the actions stored within a Traversable
container t
.
forToParallel :: forall (f :: Type -> Type) (t :: Type -> Type). (Parallel <<: f, Traversable t, Applicative f) => For t f ~> f Source #
Converts the Traversable
container-based parallel computation effect For
into the Applicative
-based parallel computation effect Parallel
.