iteratee enumPure1Chunk vs enumPureNChunks

John Lato jwlato at gmail.com
Wed Nov 2 18:58:39 GMT 2011


Today I noticed an odd difference of behavior regarding enumPure1Chunk
and enumPureNChunks when provided with an empty input.  Consider the
following:

> Prelude Data.Iteratee Control.Monad Control.Monad.Identity> enumPureNChunk ([]::[Int]) 1 chunkLength >>= run
> Nothing
> Prelude Data.Iteratee Control.Monad Control.Monad.Identity> enumPure1Chunk ([]::[Int]) chunkLength >>= run
> Just 0

As this demonstrates, enumPure1Chunk will pass null inputs to an
iteratee, whereas enumPureNChunk will ignore them and return the
original iteratee.

It's been a design principle that empty streams signify no data
currently available and can be safely discarded by enumerators,
so I think the enumPureNChunk behavior is preferable.  It's not
impossible that somebody is relying upon the current behavior,
although I wouldn't consider that a supported usage.

If there are no objections, I propose changing the behavior of
enumPure1Chunk to match enumPureNChunk.

John



More information about the Iteratee mailing list