[Haskell-cafe] different arities

Keith Wansbrough Keith.Wansbrough at cl.cam.ac.uk
Wed Nov 3 11:17:10 EST 2004

> > Haskell (http://www.haskell.org/onlinereport/decls.html). The use of "arity"
> BTW, what might the reason for that be, is it for the sake of ease of
> translation/implementation, or for the sake of some principle?   I
> mean, as soon as a person realises that there are multiple syntaxes
> for declaring a function, he/she will unify them to one abstract
> function in the head (where the resulting type matters, not the
> syntax).

The two reasons that occur to me are:

(i) to catch more errors, specifically, to catch the error of
    accidentally missing an argument.  Consider:

f False False = 0
f False True  = 1
f True        = error "TF not allowed"
f True  True  = 3

Without the rule, this would be accepted; with the rule, it is
rejected - rightly so, I think.

(ii) to make the meaning of pattern-matching easier to define and more
regular.  The current definition (sec of the report - see the
Translation sidebar) makes essential use of the fact that the array of
patterns is rectangular.  Without this, the precise order of matching
might be ambiguous, or at least harder to define.



--KW 8-)

More information about the Haskell-Cafe mailing list