Tue, 24 Aug 1999 09:28:51 -0700 (PDT), Ronald J. Legere <[EMAIL PROTECTED]> pisze:

> It WOULD be nice if you could match on functions and not just
> constructors. But I presume that the constructor/function dichotomy
> in Haskell is what allows it to be strongly typed?

How would you define the semantics of matching on functions? This is
like computing the inverse of arbitrary functions or solving arbitrary
equations! For example,

case "foo" of a++b -> (a, b)

Should it return ("f", "oo"), or ("foo", ""), or what?

Such concept is used only in n+k patterns, which may be removed
from future versions of Haskell. It arbitrarily requires k to be
a literal and succeeds only when the resulting n is nonnegative.

<http://www.dcc.ufmg.br/~camarao/views.ps> proposes an extension to
Haskell which would allow matching on user-defined functions (you
must explicitly define the inverse transformation when the defined
new "constructors" are nontrivial).

(There is also a syntactic issue. Does a++b = "foo" define (++) or a
and b? This is the reason for syntactically distinguishing names of
variables and constructors.)

-- 
 __("<    Marcin Kowalczyk * [EMAIL PROTECTED] http://kki.net.pl/qrczak/
 \__/          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