
#8128: Standalone deriving fails for GADTs due to inaccessible code ----------------------------------------------+---------------------------- Reporter: adamgundry | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects valid program | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by goldfire): This seems impossible to do correctly, in the general case. For example: {{{ type family F a data Bar a where B1 :: Bar Int B2 :: Bar (F Bool) deriving instance Eq (Bar Int) }}} The instance generated by the `deriving instance` will depend on the instances for `F` that are in scope, which seems quite fragile. In particular, if the instance for `Eq` were derived out of scope of any instance for `F`, then the instance would pattern-match only on `B1`. If, later (that is, in another module), we know that `F Bool` is `Int`, then it seems we could get a pattern-match failure in the `Eq` instance. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8128#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler