#12814: Should GND infer an instance context when deriving method-free classes? -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: RyanGlScott Type: bug | Status: patch Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.0.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #11369, #12810 | Differential Rev(s): Phab:D2692 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"03e8d26fe0a8f7981a76550118f3c584cad76c47/ghc" 03e8d26f/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="03e8d26fe0a8f7981a76550118f3c584cad76c47" Prevent GND from inferring an instance context for method-less classes When `GeneralizedNewtypeDeriving` is used with a type class that has no methods, it will generate a redundant context, and as a result, it can trigger warnings when compiled with `-Wredundant-constraints`. This is a simple change in behavior to check beforehand if a class has methods when deriving it with GND, and if it has no methods, avoid inferring the redundant context. Beware that the test for #6088, which used to be expected to fail, now compiles without issue since it doesn't infer a problematic instance context. Thanks to Simon Peyton Jones for doing the necessary refactoring in f05d685ae05ec293083f2fa7ec7ba057fbe64869. Fixes #12814. Test Plan: ./validate Reviewers: goldfire, rwbarton, simonpj, austin, bgamari Reviewed By: simonpj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2692 GHC Trac Issues: #12814 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12814#comment:15> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler