bug: strange type class member accepted
Bernard James POPE
bjpop at cs.mu.OZ.AU
Wed Jun 18 04:02:13 EDT 2003
Hi,
It appears that GHC 6.0 and 5.04.3 accept this code:
module Main where
class Foo a where
bug :: ()
-- main is not involved in the problem, just here for completeness
main :: IO ()
main = undefined
However, "bug" violates the requirement in the Report:
section 4.3.1 Class Declarations
class cx => C u where cdecls
The type of the top-level class method vi is:
vi :: forall u,w. (C u, cxi) =>ti
The ti must mention u;
^^^^
The type of "bug" does not mention the variable "a".
ghc/ghci accepts this code without error, or even warning, and it is even possible
to make instances of this class.
However, there does not seem to be any way to use "bug" without getting
a type error, so I doubt this is a big problem in practice.
For comparison hugs reports a type error message.
Cheers,
Bernie.
More information about the Glasgow-haskell-bugs
mailing list