| Copyright | 2013-2017 Luis Pedro Coelho |
|---|---|
| License | MIT |
| Maintainer | [email protected] |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Data.Conduit.Algorithms.Utils
Description
A few miscellaneous conduit utils
Documentation
awaitJust :: Monad m => (a -> Conduit a m b) -> Conduit a m b Source #
Act on the next input (do nothing if no input). awaitJust f is equivalent to
do
next <- C.await
case next of
Just val -> f val
Nothing -> return ()
This is a simple utility adapted from http://neilmitchell.blogspot.de/2015/07/thoughts-on-conduits.html
groupC :: Monad m => Int -> Conduit a m [a] Source #
groupC yields the input as groups of n elements. If the input is not a
multiple of n, the last element will be incomplete
Example:
CC.yieldMany [0..10] .| groupC 3 .| CC.consumeList
results in [ [0,1,2], [3,4,5], [6,7,8], [9, 10] ]
This function is deprecated; use chunksOf