On Jul 18, 2009, at 6:35 AM, Christopher Done wrote:
[non-linear patterns]
This kind of matching is provided in Prolog and Erlang.
Neither of them lets the user define equality.
We find the same issue with
n+k patterns (e.g., n+1 as a pattern)
l++r patterns (e.g., "prefix"++tail)
(x,x) patterns (hidden ==)
In each case, the question is "what if the Prelude's version
of the explicit or implied function is not in scope?" (For
n+k patterns, is the relevant function "+" or is it ">=" and "-"?
For l++r patterns, is it "++", or "null", "head", and "tail"?)
My preferred answer would be to say "the only functions in
scope in a pattern are constructors; these aren't functions,
they're syntax, and they always relate to the Prelude."
The Haskell' community's preferred answer seems to be
"avoid the question, ban the lot of them."
It's fair to say that any such pattern _can_ be rewritten to
something Haskell can handle; it's also fair to say that the
result is often less readable, but that a rewrite may reduce
the pain.