[Haskell-cafe] conflicting variable definitions in pattern

Janis Voigtlaender voigt at tcs.inf.tu-dresden.de
Fri May 15 04:10:53 EDT 2009

Martin Hofmann wrote:
> It is pretty clear, that the following is not a valid Haskell pattern:
> foo (x:x:xs) = x:xs
> My questions is _why_ this is not allowed. IMHO, the semantics should be
> clear: The pattern is expected to succeed, iff 'x' is each time bound to
> the same term. 
> Isn't this allowed, because this would require a strict evaluation of
> the 'x' variables?

One reason is:

What if the list were a list of functions? How would you decide
"sameness" of lambda-terms? By investigating their in-memory
representations? By trying to prove that they denote the same
mathematical function?

Ciao, Janis.

Dr. Janis Voigtlaender
mailto:voigt at tcs.inf.tu-dresden.de

More information about the Haskell-Cafe mailing list