iteratee enumPair incorrectly propagating the stream

John Lato jwlato at gmail.com
Thu Mar 3 08:40:04 GMT 2011


Thanks very much for this patch.  It's definitely a better implementation
than the old version and it's been pushed.

I wonder if enum3, enum4, and enum5 would be better names than the
spelled-out version.  It would be consistent with the "zip" functions.  And
maybe enumPair should have its name changed also, maybe "enumZip", or just
"eZip".  That would have to wait for a major release unfortunately, but the
new name could be introduced now.

Thoughts?  I'll put a new release on Hackage after I get some feedback about
the names.

John

On Thu, Mar 3, 2011 at 6:10 AM, Maciej Wos <maciej.wos at gmail.com> wrote:

> 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
>
> _______________________________________________
> Iteratee mailing list
> Iteratee at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/iteratee
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/iteratee/attachments/20110303/bb6bbbb0/attachment.htm>


More information about the Iteratee mailing list