iteratee countBytes, modifier which counts 'bytes'

Alex Lang lang at tsurucapital.com
Fri Jan 6 09:34:08 GMT 2012


Here is an updated patch which addresses some of the issues raised by Michael.

> 1) function name is very misleading, it should be called something
> like countElements or countConsumed

Indeed, I've changed the name to countConsumed for now.

> 2) function ignores value passed inside EOF constructor which means it
> can be controlled from Enumerator

I am threading the EOF streams through so I don't believe this is an issue

> 3) I suspect that "newLen = n + fromIntegral (LL.length c)" will cause
> memory leak because of lazyness.

Indeed, fixed in the new patch

Additionally, I've also changed the counter to be of generic Integral
type rather than Int64. In private communication with Michael, he
suggested that the type might as well be Integer, like some other
functions in GHC, which index into files:

hSeek :: Handle -> SeekMode -> Integer -> IO ()
hFileSize :: Handle -> IO Integer

This sounds reasonable to me.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: countConsumed.patch
Type: text/x-patch
Size: 12787 bytes
Desc: not available
URL: <http://projects.haskell.org/pipermail/iteratee/attachments/20120106/4518a25b/attachment.bin>


More information about the Iteratee mailing list