batch

Simplify queuing up data and processing it in batch. https://github.com/agrafix/batch#readme

Latest on Hackage:0.1.0.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

BSD3 licensed by Alexander Thiemann
Maintained by mail@athiemann.net

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]

Changes

Changelog for batch

0.1.0.0

  • First release

Unreleased changes

comments powered byDisqus