learning to love laziness

Norman Ramsey nr at eecs.harvard.edu
Wed Sep 24 18:07:53 EDT 2003


Consider the following Haskell function:

> asPair x = (fst x, snd x)

This function has type forall a b. (a, b) -> (a, b)
and is almost equivalent to the identity function, except it
can be used to make programs terminate that might otherwise fall
into a black hole.

My students are extremely mystified by such functions---and I can hardly
blame them!  Is there a good place to read about programming with lazy
evaluation that will cover such functions and when to use them?


Norman


More information about the Haskell mailing list