iteratee enumPair incorrectly propagating the stream

Maciej Wos maciej.wos at gmail.com
Thu Mar 3 06:10:11 GMT 2011


Hello,

I've noticed that enumPair can behave a little strange. In some cases
it returns a part of the stream it has already consumed; this is tied
to the length of the chunk it is given:

> run =<< I.enumPureNChunk [1..10 :: Int] 1 ((I.enumPair I.head (I.head >> I.head >> I.head)) >> I.stream2list)
[4,5,6,7,8,9,10]
> run =<< I.enumPureNChunk [1..10 :: Int] 2 ((I.enumPair I.head (I.head >> I.head >> I.head)) >> I.stream2list)
[4,5,6,7,8,9,10]
> run =<< I.enumPureNChunk [1..10 :: Int] 3 ((I.enumPair I.head (I.head >> I.head >> I.head)) >> I.stream2list)
[2,3,4,5,6,7,8,9,10]
> run =<< I.enumPureNChunk [1..10 :: Int] 5 ((I.enumPair I.head (I.head >> I.head >> I.head)) >> I.stream2list)
[2,3,4,5,6,7,8,9,10]

I found the implementation in the library hard to follow, so I written
a new version from scratch. I also added enumThree, enumFour and
enumFive for a good measure -- I've used something like enumFive in my
code before and I think they would be nice to have.

I've attached a patch with the changes.

-- Maciej
-------------- next part --------------
A non-text attachment was scrubbed...
Name: enumPair.dpatch
Type: application/octet-stream
Size: 5907 bytes
Desc: not available
URL: <http://projects.haskell.org/pipermail/iteratee/attachments/20110303/7aa02b01/attachment.obj>


More information about the Iteratee mailing list