
#10562: GHC 7.10.2 RC cannot build boolsimplifier-0.1.8 -------------------------------------+------------------------------------- Reporter: snoyberg | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.2 Component: Compiler | Version: 7.10.2-rc1 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: GHC rejects | (amd64) valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by gershomb): So the relevant lines seem to be: {{{ data QueryRep qtyp a where QAtom :: (Ord a) => a -> QueryRep QAtomTyp a QOp :: (Show qtyp, Ord a) => Set (QueryRep QAtomTyp a) -> Set (QueryRep (QFlipTyp qtyp) a) -> QueryRep qtyp a instance (Eq a) => Eq (QueryRep qtyp a) where (QAtom x) == (QAtom y) = x == y (QOp as cs) == (QOp as' cs') = as == as' && cs == cs' _ == _ = False -- can't happen instance (Ord a) => Ord (QueryRep qtyp a) where compare (QAtom x) (QAtom y) = compare x y compare (QOp as cs) (QOp as' cs') = compare as as' `mappend` compare cs cs' compare (QAtom _) _ = GT -- can't happen compare _ _ = LT -- can't happen }}} And the relevant error seems to be {{{ Overlapping instances for Eq (QueryRep (QFlipTyp qtyp) a) arising from a use of ‘compare’ }}} With the additional info: {{{ There exists a (perhaps superclass) match: from the context (Eq (QueryRep qtyp a), Ord a) bound by the instance declaration at Data/BoolSimplifier.hs:116:10-41 or from (Show qtyp, Ord a) bound by a pattern with constructor QOp :: forall qtyp a. (Show qtyp, Ord a) => Set (QueryRep QAtomTyp a) -> Set (QueryRep (QFlipTyp qtyp) a) -> QueryRep qtyp a, in an equation for ‘compare’ at Data/BoolSimplifier.hs:118:14-22 or from (Show qtyp, Ord a) bound by a pattern with constructor QOp :: forall qtyp a. (Show qtyp, Ord a) => Set (QueryRep QAtomTyp a) -> Set (QueryRep (QFlipTyp qtyp) a) -> QueryRep qtyp a, in an equation for ‘compare’ at Data/BoolSimplifier.hs:118:26-36 (The choice depends on the instantiation of ‘qtyp, a’ To pick the first instance above, use IncoherentInstances when compiling the other instance declarations) In the second argument of ‘mappend’, namely ‘compare cs cs'’ In the expression: compare as as' `mappend` compare cs cs' In an equation for ‘compare’: compare (QOp as cs) (QOp as' cs') = compare as as' `mappend` compare cs cs' }}} So what's happening is we've asserted there's an `Ord a` dictionary three different ways -- first and second from packing it in each of the two GADTs, and third from the constrain in the instance head. Interestingly, it doesn't seem to balk at duplicate `Ord` instances themselves, but from the fact that they lead to duplicate `Eq` instances. To be honest, I don't remember why the `Ord` constraint is ever packed with the GADT at all. But, regardless, this seems like something the compiler should be able to handle properly, and it seems like a regression if it can't? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10562#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler