snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
152 stars 63 forks source link

Adding `chucksOfE`? #142

Closed luispedro closed 6 years ago

luispedro commented 6 years ago

I plan to write a function along the lines of (In fact, I have already written a variation of this at least 5 times on different projects, which is why I want it on some library):

chunksOfE :: (IsSequence seq) -> Index seq -> Conduit seq m seq

Every sequence it yields (except the last) will have the given number of elements. We can also have chunksOfExactlyE which would not yield a final element if it is not big enough (it'd be a leftover).

If you think it could fit here, I'll do it as a PR here; otherwise I will add it to conduit-algorithms.

(Maybe there is a simple way to do this already in conduit-combinators, but I always end up writing it).

snoyberg commented 6 years ago

I don't see a problem with such an addition, PR welcome :)

snoyberg commented 6 years ago

Fixed by #143, thanks!