| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
Morley.Util.Batching
Synopsis
- data BatchingM i o e a
 - runBatching :: Functor m => ([i] -> m (r, [o])) -> BatchingM i o e a -> m (r, Either (BatchingError e) a)
 - unsafeRunBatching :: (Functor m, Buildable e) => ([i] -> m (r, [o])) -> BatchingM i o e a -> m (r, a)
 - submitThenParse :: i -> (o -> Either e a) -> BatchingM i o e a
 - data BatchingError e
 
Documentation
data BatchingM i o e a Source #
Records operations to be executed in batch.
Chronologically, this works in 3 steps:
- Form the list of input items 
i; - Perform the batch operation;
 - Parse output items 
ointo resulta, maybe producing errore. 
However in code we usually want steps 1 and 3 to be grouped
 and step 2 to be delayed - BatchingM facilitates this separation.
Note that BatchingM is fundamentally not a monad, rather just an applicative,
 because within a batch you cannot use result of one operation in another
 operation.
Instances
| Functor (BatchingM i o e) Source # | |
| Applicative (BatchingM i o e) Source # | |
Defined in Morley.Util.Batching Methods pure :: a -> BatchingM i o e a # (<*>) :: BatchingM i o e (a -> b) -> BatchingM i o e a -> BatchingM i o e b # liftA2 :: (a -> b -> c) -> BatchingM i o e a -> BatchingM i o e b -> BatchingM i o e c # (*>) :: BatchingM i o e a -> BatchingM i o e b -> BatchingM i o e b # (<*) :: BatchingM i o e a -> BatchingM i o e b -> BatchingM i o e a #  | |
runBatching :: Functor m => ([i] -> m (r, [o])) -> BatchingM i o e a -> m (r, Either (BatchingError e) a) Source #
Run recorded operations sequence using the given batch executor.
unsafeRunBatching :: (Functor m, Buildable e) => ([i] -> m (r, [o])) -> BatchingM i o e a -> m (r, a) Source #
Similar to runBatching, for cases when the given batch executor
 is guaranteed to return the output respective to the provided input.
submitThenParse :: i -> (o -> Either e a) -> BatchingM i o e a infix 1 Source #
This is the basic primitive for all actions in BatchingM.
It records that given input item should be put to batch, and once operation is actually performed, the result should be parsed with given method.
data BatchingError e Source #
Errors that can occur during batching, usually because the underlying function that performs batch operation returns output that does not match the provided input.
Constructors
| InsufficientOutput | The function that executes the batch returned less elements in output than were provided at input.  | 
| ExtraOutput | The function that executes the batch returned more elements in output than were provided at input.  | 
| UnexpectedElement e | User-provided parsing method failed. Usually this means that output does not correspond to provided input.  | 
Instances
| Buildable e => Buildable (BatchingError e) Source # | |
Defined in Morley.Util.Batching Methods build :: BatchingError e -> Builder #  | |