[Haskell] insufficiently laziness@pattern -- more counterintuitive stuff

ajb at spamcop.net ajb at spamcop.net
Tue Mar 30 19:09:25 EST 2004


G'day all.

Quoting Duncan Coutts <duncan at coutts.uklinux.net>:

> Or finally, the "it's what you want most often" argument.

How about the "it's the most natural thing" argument?

Pattern matching on the LHS of a function definitions looks, for all the
world, like a set of rewrite rules.  That's because, in some sense, they
are.

In this definition:

    f (x:xs) = 1 + f xs
    f [] = []

Intuitively, the first rule should only "fire" if the expression being
evaluated conforms to the left-hand side.

A google search for "conformality check" may also help.

A potentially frightening thought is that something like the above
definition would make sense in a lazy _logic_ language.

Cheers,
Andrew Bromage


More information about the Haskell mailing list