Erroneous warning

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Mon Sep 17 12:30:35 EDT 2001


> > foo :: Int -> Int
> > foo (i+1) = i
> > foo 0 = -10
>
> Q.lhs:5: Warning: Pattern match(es) are overlapped in the definition of
> function `foo':
>             foo 0 = ...

| This is acceptbale behaviour, since the first equation can match with i = -1. 
| The type is Int, not Nat.

No, it is not acceptable according to the Haskell'98 Report, section
3.17.2, rule 4(c).  N+k patterns can only match positive ints.
That non-symmetry is one of the reasons many people would like to
get rid of this pattern form.

Regards,
    Malcolm




More information about the Glasgow-haskell-bugs mailing list