Skip to content
  • Ryan Scott's avatar
    Don't unnecessarily qualify TH-converted instances with empty contexts · ad3d2dfa
    Ryan Scott authored
    Summary:
    The addition of rigorous pretty-printer tests
    (499e4382) had the unfortunate
    side-effect of revealing a bug in `hsSyn/Convert.hs` wherein instances are
    _always_ qualified with an instance context, even if the context is empty. This
    led to instances like this:
    
    ```
    instance Foo Int
    ```
    
    being pretty-printed like this!
    
    ```
    instance () => Foo Int
    ```
    
    We can prevent this by checking if the context is empty before adding an
    HsQualTy to the type.
    
    Also does some refactoring around HsForAllTys in `Convert` while I was in town.
    
    Fixes #13183.
    
    Test Plan: ./validate
    
    Reviewers: goldfire, bgamari, austin, alanz
    
    Reviewed By: alanz
    
    Subscribers: mpickering, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3018
    
    GHC Trac Issues: #13183
    ad3d2dfa