#2706: Associated data type doesn't infer context
---------------------------------+------------------------------------------
Reporter: ajd | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.8.3 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown/Multiple | Os: Unknown/Multiple
---------------------------------+------------------------------------------
The following code fails to compile:
{{{
class Eq a => Bar a where
bar :: a -> Int
class Bar (Baz a) => Foo a where
data Baz a :: *
foo :: Baz a -> Baz a
data Bang a = Bang (Baz a) deriving Eq
}}}
The error message is
{{{
test.hs:8:36:
No instance for (Eq (Baz a))
arising from the 'deriving' clause of a data type declaration
at test.hs:8:36-37
Possible fix: add an instance declaration for (Eq (Baz a))
When deriving the instance for (Eq (Bang a))
}}}
If I add a context of {{{Foo a}}} to {{{Bang}}}, it compiles, but since
{{{Baz}}} is only defined on instances of {{{Foo}}}, shouldn't GHC be able
to figure out that {{{Baz a}}} always has an {{{Eq}}} instance?
In any case, the error message is misleading, since there already ''is'' a
context for {{{Baz a}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2706>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs