https://github.com/agrafix/batch
Haskell: Simplify queuing up data and processing it in batch.
https://github.com/agrafix/batch
Last synced: about 2 months ago
JSON representation
Haskell: Simplify queuing up data and processing it in batch.
- Host: GitHub
- URL: https://github.com/agrafix/batch
- Owner: agrafix
- License: bsd-3-clause
- Created: 2018-01-27T08:29:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-27T08:32:12.000Z (over 8 years ago)
- Last Synced: 2026-03-12T04:06:11.850Z (3 months ago)
- Language: Haskell
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# batch
[](https://circleci.com/gh/agrafix/batch)
Simplify queuing up data and processing it in batch.
```haskell
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]
```