
#10675: GHC does not check the functional dependency consistency condition correctly -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Resolution: | Keywords: FunDeps Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by diatchki): Hello, I just saw this, sorry for the very late reply. I don't think that the original example technically violates the FD property as the second instance (the one with `C Char ...`) is vacuous and doesn't actually add any new instances to `C` (there is no base case). The first instances on its own is OK, so the whole program is OK. I am not sure that this is any easy thing to spot in general though. There is, however, a real problem with the consistency checking of FDs though, as illustrated by the following example: {{{ class F tag a b | a -> b class G a b | a -> b class H a b | a -> b instance G a b => F Int [a] [b] instance H a b => F Char [a] [b] instance G Int Int instance H Int Char }}} These instances are accepted by GHC 8.0.1 but are inconsistent, because we can derive both `F Int [Int] [Int]` and `F Char [Int] [Char]` which violates the FD on `F`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10675#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler