[Haskell-cafe] Re: Left fold enumerator - a real pearl overlooked?

Don Stewart dons at galois.com
Wed Mar 4 13:08:47 EST 2009

> On Tue, Mar 3, 2009 at 1:03 AM, Henning Thielemann
> <lemming at henning-thielemann.de> wrote:
> >
> > On Mon, 2 Mar 2009, John Lato wrote:
> >
> > While I think that the Iteratee pattern has benefits, I suspect that it
> > can't be combined with regular lazy functions, e.g. of type [a] -> [a]. Say
> > I have a chain of functions: read a file, parse it into a tag soup, parse
> > that into an XML tree, transform that tree, format that into a string, write
> > that to a file, and all of these functions are written in a lazy way, which
> > is currently considered good style, I can't use them in conjunction with
> > iteratees. This means, almost all Haskell libraries have to be rewritten or
> > extended from lazy style to iteratee style. The question for me is then: Why
> > having laziness in Haskell at all? Or at least, why having laziness by
> > default, why not having laziness annotation instead of strictness
> > annotation.
> >
> I'm not sure that this is a problem, at least not for all cases.  When
> reading seekable streams, it is possible to have IO on demand provided
> that all processing take place within the context of the Iteratee (see
> Oleg's Tiff reader, http://okmij.org/ftp/Haskell/Iteratee/Tiff.hs, and
> my wave reader,
> http://inmachina.net/~jwlato/haskell/iteratee/src/Data/Iteratee/Codecs/Wave.hs).

BTW, I've started (with his blessing) packaging up Oleg's Haskell code:


So you can use, e.g., the left-fold based TIFF parser:


I'm walking backwards over his released modules, adding a few each day.

-- Don

More information about the Haskell-Cafe mailing list