iteratee countBytes, modifier which counts 'bytes'

Michael Baikov manpacket at gmail.com
Thu Jan 5 10:22:45 GMT 2012


Hello Alex

1) function name is very misleading, it should be called something
like countElements or countConsumed
2) function ignores value passed inside EOF constructor which means it
can be controlled from Enumerator
3) I suspect that "newLen = n + fromIntegral (LL.length c)" will cause
memory leak because of lazyness.

On Thu, Jan 5, 2012 at 2:03 PM, Alex Lang <lang at tsurucapital.com> wrote:
> Here is a patch for a function
>
> countBytes :: forall m s a el. (Monad m, LL.ListLike s el, Nullable s)
> => I.Iteratee s m a -> I.Iteratee s m (a, Int64)
>
> which keeps track of the number of 'bytes' (in fact not necessarily
> bytes) consumed by an iteratee. It was inspired by countBytes in
> snap-core[0], and Conrad Parker has had some use for it. I've also
> included a quickcheck test called prop_countBytes. Perhaps something
> like countUsage or trackUsage is a better name?
>
> [0] http://hackage.haskell.org/packages/archive/snap-core/0.6.0.1/doc/html/src/Snap-Iteratee.html#countBytes
>
> _______________________________________________
> Iteratee mailing list
> Iteratee at projects.haskell.org
> http://projects.haskell.org/cgi-bin/mailman/listinfo/iteratee
>



More information about the Iteratee mailing list