[GHC] #13183: Template Haskell needlessly pretty-prints empty instance contexts

GHC ghc-devs at haskell.org
Thu Jan 26 17:48:42 UTC 2017


#13183: Template Haskell needlessly pretty-prints empty instance contexts
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Template Haskell  |              Version:  8.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Other             |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D3018
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ryan Scott <ryan.gl.scott@…>):

 In [changeset:"ad3d2dfa19a1ed788c682e8b0c7c6e66e63d3f79/ghc"
 ad3d2dfa/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="ad3d2dfa19a1ed788c682e8b0c7c6e66e63d3f79"
 Don't unnecessarily qualify TH-converted instances with empty contexts

 Summary:
 The addition of rigorous pretty-printer tests
 (499e43824bda967546ebf95ee33ec1f84a114a7c) 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
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13183#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list