Safe Haskell | None |
---|---|
Language | Haskell2010 |
An Applicative
for deferring "requests" to handle them all in bulk.
Synopsis
- data Batching rq rs a
- request :: rq -> Batching rq rs rs
- batchRequest :: forall t rq rs. Traversable t => t rq -> Batching rq rs (t rs)
- runBatching :: Functor f => (forall n. Vec n rq -> f (Vec n rs)) -> Batching rq rs a -> f a
- runBatching_ :: (forall n. Vec n rq -> Vec n rs) -> Batching rq rs a -> a
Documentation
data Batching rq rs a Source #
The bulk request-response Applicative.
A value of type Batching rq rs a
describes a computation that gathers some
number of rq
request values, expects the same number of rs
response
values, and ultimately returns an a
result value derived from the
responses.
This can be used to apply an offline resource allocation algorithm to code written as if allocation requests were satisfied incrementally.
This synergizes well with -XApplicativeDo
, which allows using do-notation
for this type, as long as requests do not depend on earlier responses.
Instances
Functor (Batching rq rs) Source # | |
Applicative (Batching rq rs) Source # | |
Defined in Control.Batching pure :: a -> Batching rq rs a # (<*>) :: Batching rq rs (a -> b) -> Batching rq rs a -> Batching rq rs b # liftA2 :: (a -> b -> c) -> Batching rq rs a -> Batching rq rs b -> Batching rq rs c # (*>) :: Batching rq rs a -> Batching rq rs b -> Batching rq rs b # (<*) :: Batching rq rs a -> Batching rq rs b -> Batching rq rs a # |
batchRequest :: forall t rq rs. Traversable t => t rq -> Batching rq rs (t rs) Source #
Issue a Traversable of requests and retrieve their responses.
runBatching :: Functor f => (forall n. Vec n rq -> f (Vec n rs)) -> Batching rq rs a -> f a Source #
runBatching_ :: (forall n. Vec n rq -> Vec n rs) -> Batching rq rs a -> a Source #
Like runBatching
, but without a Functor
(or implicitly in Identity
).