batch: Simplify queuing up data and processing it in batch.

[ bsd3, data, library ] [ Propose Tags ]

Simplify queuing up data and processing it in batch.


[Skip to Readme]
Versions 0.1.0.0
Change log ChangeLog.md
Dependencies async (>=2.0), base (>=4.7 && <5), lifted-async (>=0.9), lifted-base (>=0.2.3), monad-control (>=1.0), mtl (>=2.2), stm (>=2.4), timespan (>=0.3), transformers-base (>=0.4) [details]
License BSD-3-Clause
Copyright 2017 Alexander Thiemann <mail@athiemann.net>
Author Alexander Thiemann
Maintainer mail@athiemann.net
Category Data
Home page https://github.com/agrafix/batch#readme
Bug tracker https://github.com/agrafix/batch/issues
Source repo head: git clone https://github.com/agrafix/batch
Uploaded by AlexanderThiemann at Sat Jan 27 08:49:14 UTC 2018
Distributions NixOS:0.1.0.0
Downloads 114 total (13 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2018-01-27 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for batch-0.1.0.0

[back to package description]

batch

CircleCI

Simplify queuing up data and processing it in batch.

import Control.Batch
import Control.Concurrent.STM
import Control.Monad

example :: IO ()
example =
  do outVar <- atomically $ newTVar []
     let cfg =
             Batch
             { b_runEveryItems = Just 5
             , b_runAfterTimeout = Nothing
             , b_maxQueueLength = Nothing
             , b_runBatch =
                     \x -> atomically $ modifyTVar' outVar (++x)
             }
     withBatchRunner cfg $ \hdl ->
         do replicateM_ 5 $ bh_enqueue hdl True
            out <-
                atomically $
                do x <- readTVar outVar
                   when (length x /= 5) retry
                   pure x
            out `shouldBe` [True, True, True, True, True]