In addition to the other arguments mentioned, there is the practical concern
that it becomes quite easy to introduce non-termination by a simple typo:

  f [1...] [2..] where f x x = x  --- oops!

versus, say, the intended

  f [1..] [2..] where f x y = x  .

Or, even more more common:

  f (x@(x,y)) = ... --- oops!

It would be a tad more acceptable, IMO, if one could at least require that
the strictness and equality constraints were expressed explicitly in a
signature, similar to the situation for polymorphic recursion, say like this
(I hope this was the correct usage of Eval; I never really used it much...):

  f :: (Eval a, Eq a) => a -> a -> a
  f x x = x

Anyway, I agree with Brian, who said that this is such a limited class of
constraints that it is not really worth going the extra mile...

--FC

> A friend and I recently discussed why patterns in Haskell are
> restricted to be linear. He found it unintuitive due to his background
> in term rewriting and logic. And he noted that it is easy to compile
> away as in:
...
> My main argument against it was a language design issue, namely that
> suddenly x is required to have an Eq type which cannot be explained by
> looking at its uses in e.
>
> Another problem is that comparing x with x' makes this kind of pattern
> matching super-strict (since x may be reduced to normal form).
>
> Can someone enlighten me on other arguments for or against non-linear
> patterns?



Reply via email to