conduit-algorithms-0.0.8.0: Conduit-based algorithms

Copyright2013-2017 Luis Pedro Coelho
LicenseMIT
Maintainerluis@luispedro.org
Safe HaskellNone
LanguageHaskell2010

Data.Conduit.Algorithms.Utils

Description

A few miscellaneous conduit utils

Synopsis

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

enumerateC :: Monad m => Conduit a m (Int, a) Source #

Conduit analogue to Python's enumerate function

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