iteratee space leaks after a semantic change to enumPure1Chunk

Akio Takano tkn.akio at
Mon Oct 31 08:15:57 GMT 2011


The program below leaks space when compiled with iteratee- or later, but
it does not with

import qualified Data.Iteratee as I

main = I.enumList (replicate 10000000 [True, False]) ( I.head I.last)
    >>= >>= print

This is due to a change introduced in It is a change of the
semantics of
enumPure1Chunk, which is called by zip. It now pushes
data into an iteratee that is in the done state. Because I.head moves
to the done state
after consuming one element, the subsequent part of the stream is
pushed into it, leading
to a space leak.

In addition to zip, enumWith suffers from the same problem.

While the change to enumPure1Chunk is marked as a bugfix, i would
rather expect the old behavior
because it's more consistent with other enumerators. Most of the
enumerators in the library
does early termination, in the sense that it stops feeding data to an
iteratee as soon as it detects
that the interatee is in the done state. So I would expect
enumPure1Chunk to do the same.
I think it's ok to drop the stream when the iteratee is done, because
if the user doesn't want to
drop any information, they can always keep their iteratee in the cont
state until it sees EOF.

Would it be a choice to change it back to the old one? I'm willing to
submit a patch in that case.

Takano Akio

More information about the Iteratee mailing list