Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data Batcher command m a
- runBatcher :: forall command m a. MonadIO m => Worker command m -> Batcher command m a -> m a
- type Worker command m = [Scheduled command m] -> m ()
- data Scheduled command m = Scheduled {
- command :: command a
- writeResult :: Either SomeException a -> m ()
- simpleWorker :: MonadCatch m => (forall r. command r -> m r) -> Worker command m
- schedule :: (MonadIO m, MonadThrow m) => command a -> Batcher command m a
- catchBatcher :: (MonadCatch m, Exception e) => Batcher command m a -> (e -> Batcher command m a) -> Batcher command m a
Documentation
data Batcher command m a Source #
An applicative monad that schedules commands for later more efficient execution.
:: MonadIO m | |
=> Worker command m | Specfies how to batch and execute commands. |
-> Batcher command m a | The computation to run. |
-> m a |
Execute a Batcher
computation using the given Worker
.
type Worker command m = [Scheduled command m] -> m () Source #
A Worker
is responsible for executing the given batch of scheduled
commands. Instead of executing each command individually it might group
commands and execute each group in one go. It might also execute each command
concurrently.
The Worker
should ensure that the result of each command is written using
writeResult
.
data Scheduled command m Source #
A
command paired with a function to communicate its result.schedule
d
Note that the result of the command is
existentially quantified.
This ensures that multiple commands with different
result types can be batched in a list which can then be given to a Worker
for execution.
Scheduled | |
|
:: MonadCatch m | |
=> (forall r. command r -> m r) | Specifies how to execute a command. |
-> Worker command m |
A convenience Worker
that simply executes commands using the given
function without any batching.
:: (MonadIO m, MonadThrow m) | |
=> command a | The command to schedule. |
-> Batcher command m a |
Schedule a command for later execution.
:: (MonadCatch m, Exception e) | |
=> Batcher command m a | The computation to run |
-> (e -> Batcher command m a) | Handler to invoke if an exception is raised |
-> Batcher command m a |
Catch and handle exceptions.