Mark T.B. Carroll wrote:
Bryan O'Sullivan <[EMAIL PROTECTED]> writes:

Mark T.B. Carroll wrote:

I'm afraid no
examples come easily to mind, though.
Here's a simple one: reading a flattened graph from disk. If your flattened representation contains forward references, you have to fix them up in a strict language. In a lazy language, you can refer to elements you haven't yet read, eliminating that book-keeping.

That's a good point. Indeed, I had used laziness in a programme that
read a file that contained a series of entity definitions that could
include forward references, I just couldn't remember exactly how I'd
used laziness. (-: (It's also useful in some memoising, I think.)

-- Mark

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Near the bottom of http://www.haskell.org/hawiki/TyingTheKnot is an example that uses lazy evaluation to do exactly this. The real kicker though, is that the change from backward references only (i.e. simplistic one-pass code that would work in a strict language) to forward and backward references is trivial (just pass in the output).
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to