Skip to content
  • Ryan Scott's avatar
    Prevent GND from inferring an instance context for method-less classes · 03e8d26f
    Ryan Scott authored
    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
    f05d685a.
    
    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
    03e8d26f