[Haskell-cafe] How is laziness defined?

Matthew Brecknell haskell at brecknell.org
Mon Feb 5 02:26:49 EST 2007

TJ said:
> I went through the entry on laziness on the wikipedia wikibook. Very
> nice. The wikibook sure has grown a lot since I last visited.
> http://en.wikibooks.org/wiki/Haskell/Laziness

Thanks for the link. I hadn't seen that before.

Although it covers irrefutable (lazy) pattern matching in the second
section, it does appear to miss the point that let bindings are always
irrefutable. Thus, there is no difference between these two:

let (x,y) = foo in ...
let ~(x,y) = foo in ...

I need to have a closer look when I have some more time, but I think
this might have lead to some inaccuracies in the first section (Thunks
and WHNF).

FYI, the Haskell 98 Report defines the non-recursive let binding in
terms of a case expression with an irrefutable pattern match. So, the
following are equivalent:

let (x,y) = foo in ...
case foo of ~(x,y) -> ...

But note that function arguments are defined in terms of case
expressions (whose patterns are refutable), so the following are *not*
equivalent (example from the wikibook):

let f (x,y) = 1 in f undefined
let f ~(x,y) = 1 in f undefined

Confused again?

> I believe I've got it now. By it I mean the understanding of laziness
> in Haskell. Even though Haskell is, strictly speaking, not lazy, but
> non-strict. "It" being but read and thought about, and not practiced,
> might prove _itself_ to become Undefined as I evaluate it further. :D

Nicely put. I think you are getting it. :-)

More information about the Haskell-Cafe mailing list