Skip to content

Instantly share code, notes, and snippets.

@etorreborre
Created April 28, 2019 13:37
Show Gist options
  • Select an option

  • Save etorreborre/2dc356a329e92a2df71f852cc930264c to your computer and use it in GitHub Desktop.

Select an option

Save etorreborre/2dc356a329e92a2df71f852cc930264c to your computer and use it in GitHub Desktop.
output-batched.hs
newBatchedOutput :: (Monad m) => Tag "unbatched" (Output m) -> Output m
newBatchedOutput output = Output {
saveOutputs = concat . saveOutputs (unTag output). batchesOf 500
}
batchesOf :: (Monad m) => Int -> Stream (Of a) m r -> Stream (Of [a]) m r
batchesOf batchSize = mapsM toList . chunksOf batchSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment