iteratee enumPair incorrectly propagating the stream

Maciej Wos maciej.wos at gmail.com
Fri Mar 4 03:42:26 GMT 2011


+1 for zip, zip2, zip3, sequence ...

One has to import Iteratee.ListLike qualified anyway (or hide a myriad
of Prelude's functions). Plus, we already have filter, not enumFilter
or take, not enumTake, etc. So, enumPair/enum2/enumZip wouldn't really
fit in.

-- Maciej

On Fri, Mar 4, 2011 at 12:19 PM, Conrad Parker <conrad at metadecks.org> wrote:
> On 3 March 2011 17:40, John Lato <jwlato at gmail.com> wrote:
>> 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.
>
> consistency would be good, eg.:
>
> enum2, enum3, enum4 ...
>
> or
>
> enumZip, enumZip3, enumZip4 ...
>
> also it would be worth noting in the documentation that enumSequence
> is a similar operation over lists.
>
> bikeshedding, I don't think eZip is very descriptive. OTOH if we want
> short names to use qualified, perhaps just use zip, zip2, sequence
> etc. (ie. I.zip, I.zip2, I.sequence ...)
>
> Conrad.
>
>>
>> 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
>>>
>>
>>
>> _______________________________________________
>> Iteratee mailing list
>> Iteratee at projects.haskell.org
>> http://projects.haskell.org/cgi-bin/mailman/listinfo/iteratee
>>
>>
>



More information about the Iteratee mailing list