#7543: Constraint synonym instances ---------------------------------+------------------------------------------ Reporter: monoidal | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.1 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by simonpj):
* difficulty: => Unknown Comment: I can see your point; and I agree it's odd that it's accepted when no methods are given. But it's not easy to fix in the way you want. Here's why. Suppose we have {{{ class C a where reverse :: a -> a instance C Int where reverse x = x }}} When GHC encounters the binding `reverse x = x`, it has to figure out which `reverse` you mean -- there are two in scope. Ah! Since this is in an instnace declaraction, it must be the one that's method of class `C`, not the one from `Prelude`. This scope resolution is done by the '''renamer'''. The renamer does not understand type synonyms (they are interpreted by the subsequent '''type checker'''), so it can't figure out that `Ring` really means `Num` in your example. I can't see an easy way round this in GHC's current structure. The only think that comes to mind is to postpone all scope resolution for instance bindings until the type checker. But that would mean a bit of an upheaval of datatypes etc. Quite do-able, but not very simple. As things stand it might be more consistent to reject an instance declaration if the "class" turns out to be a synonym. I'm rather inclined to do nothing! Simon -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7543#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs