Hi Volker,

It is legal Haskell,  but it isn't doing what you think.  The patterns 
in a case statement introduce *new* variables, their scope is the
right hand side expression of their alternative.

Since the a,b,c patterns are just variables they will match anything,
and the first alternative will always succeed. Hence the warning from GHC.  

I'm not sure that GHC could, in general, produce a better error
message. 

regards
Kevin




Volker Wysk writes:
 > Hello.
 > 
 > Compiling the following with ghc-4.06 produces an erroneous error message:
 > 
 > module O where
 > 
 > a :: Int
 > a = 1
 > 
 > b :: Int
 > b = 2
 > 
 > c :: Int
 > c = 3
 > 
 > f :: Int -> Bool
 > f i = case i of
 >    a -> True
 >    b -> True
 >    c -> True
 > 
 > 
 > The compiler complains:
 > 
 > o.hs:14: Pattern match(es) are overlapped in a group of case alternatives
 > beginning
 >                                            a:
 >          b -> ...
 >          c -> ...
 > 
 > 
 > The program may be wrong. (Is this legal?). But the error message
 > certainly is wrong.
 > 
 > 
 > bye
 > 
 > 

Reply via email to