Tue, 25 Jan 2000 15:33:25 -0800, Craig Dickson <[EMAIL PROTECTED]> pisze:

> If "(x:xs)" does not match [], then the reason for this should be
> that [] has no head to bind to x, nor tail to bind to xs;

No, the reason is simply that [] and (:) are distinct constructors.

E.g. the pattern Nothing does not match Just 5 even though there is
no variable that can't be bound.

Pattern matching must do what the semantics of the language requires.
On the other hand, functions can be defined to do anything that
is expressable.

> "head []", "tail []", and "take 1 []" should also fail.

If take would be spelled "take at most", it would certainly not be
required to fail, right? But the name "take" is simpler and the only
difference between the two is that take is defined on more values
(with the "obvious" meaning), has no runtime penalties, so it suffices.

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/              GCS/M d- s+:-- a22 C+++$ UL++>++++$ P+++ L++>++++$ E-
  ^^                  W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK                  5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-

Reply via email to