Erroneous warning

Simon Marlow simonmar at microsoft.com
Mon Sep 17 12:37:20 EDT 2001


> Ian Lynagh wrote:
> 
> > If Q.lhs is
> > 
> > > module Q where
> > 
> > > foo :: Int -> Int
> > > foo (i+1) = i
> > > foo 0 = -10
> > 
> > then
> > 
> > % ghc -c -o Q.o Q.lhs
> > 
> > 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.

Nope, (n+k) matches x when x >= k.  In other words, n >= 0.  The warning
is indeed wrong.

It's about time we started warning about *all* uses of n+k patterns, not
just the wrong ones.  n+k: Just Say No :-)

Cheers,
	Simon




More information about the Glasgow-haskell-bugs mailing list