GHC bug,or Hugs feature?
Malcolm Wallace
Malcolm.Wallace@cs.york.ac.uk
Wed, 7 Aug 2002 13:48:49 +0100
Arthur Baars <arthurb@cs.uu.nl> writes:
> f :: a -> a
> f a | True = a
> | g 'a' == 'a' = g a
>
> g :: a -> a
> g a | True = a
> | f 'a' == 'a' = f a
>
> Is this a bug in GHC or a feature of Hugs?
> I did not check what NHC and other Haskell compilers say about this. Can
> someone try?
nhc98 agrees with GHC rather than Hugs. The code above compiles fine.
If you omit one type signature, the error is
Derived type for Test.f at 4:1 does not match due to:
given free variable a is bound to Prelude.Char
Derived:(Prelude.Char -> Prelude.Char)
Given :(a -> a)
If you omit both signatures, f and g are typed as Char->Char.
With or without type signatures, nhc98 additionally emits warnings:
====== Warning pattern removal:
Alternative at 9:22 is hidden by alternative at 8:7
Alternative at 5:22 is hidden by alternative at 4:7
Regards,
Malcolm