[GHC] #13887: Template Haskell pretty-printer doesn't parenthesize infix datatype names in data declarations

GHC ghc-devs at haskell.org
Fri Jul 7 20:39:41 UTC 2017


#13887: Template Haskell pretty-printer doesn't parenthesize infix datatype names
in data declarations
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Template Haskell  |              Version:  8.0.1
      Resolution:                    |             Keywords:  newcomer
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Thanks for looking into this, ak3n!

 I don't believe changing the implementation of `pprName` is what you want
 here, since that will affect far more than just infix datatypes names,
 which is what you really care about. I think your second suggestion
 (changing uses of `ppr` to `pprName' Applied`) is on the right track.

 As far as why the type of `Refl1_3` is pretty-printed incorrectly, I
 //think// it's due to the pretty-printer for `Type`. It has a case for
 `ConT` [https://git.haskell.org/ghc.git/blob/HEAD:/libraries/template-
 haskell/Language/Haskell/TH/Ppr.hs#l682 here]:

 {{{#!hs
 pprParendType (ConT c)            = ppr c
 }}}

 I think this should be `pprName' Applied c` instead. This is consistent
 with the pretty-printer's
 [https://git.haskell.org/ghc.git/blob/3c4537ea1c940966eddcb9cb418bf8e39b8f0f1c:/libraries
 /template-haskell/Language/Haskell/TH/Ppr.hs#l128 treatment] for `Exp` as
 well:

 {{{#!hs
 pprExp _ (ConE c)     = pprName' Applied c
 }}}

 So that feels like the right solution.

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


More information about the ghc-tickets mailing list