[commit: ghc] master: Follow-up to #13887, for promoted infix constructors (7089dc2)

git at git.haskell.org git at git.haskell.org
Sun Jul 30 00:04:17 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/7089dc2f12f9616771fc1de143e9b974157405d8/ghc

>---------------------------------------------------------------

commit 7089dc2f12f9616771fc1de143e9b974157405d8
Author: Ryan Scott <ryan.gl.scott at gmail.com>
Date:   Sat Jul 29 19:36:42 2017 -0400

    Follow-up to #13887, for promoted infix constructors
    
    Summary:
    Correct a couple more spots in the TH pretty-printer by applying the
    appropriate parenthesization for infix names. Fixes #13887 (again).
    
    Test Plan: make test TEST=T13887
    
    Reviewers: austin, bgamari
    
    Subscribers: rwbarton, thomie
    
    GHC Trac Issues: #13887
    
    Differential Revision: https://phabricator.haskell.org/D3802


>---------------------------------------------------------------

7089dc2f12f9616771fc1de143e9b974157405d8
 libraries/template-haskell/Language/Haskell/TH/Ppr.hs |  4 ++--
 testsuite/tests/th/T13887.hs                          | 13 +++++++++++++
 testsuite/tests/th/T13887.stdout                      |  3 +++
 testsuite/tests/th/TH_PromotedList.stderr             |  4 ++--
 testsuite/tests/th/TH_RichKinds2.stderr               |  5 +++--
 testsuite/tests/th/all.T                              |  1 +
 6 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs
index 696c445..e6c3302 100644
--- a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs
+++ b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs
@@ -689,11 +689,11 @@ pprParendType (UnboxedSumT arity) = hashParens $ hcat $ replicate (arity-1) bar
 pprParendType ArrowT              = parens (text "->")
 pprParendType ListT               = text "[]"
 pprParendType (LitT l)            = pprTyLit l
-pprParendType (PromotedT c)       = text "'" <> ppr c
+pprParendType (PromotedT c)       = text "'" <> pprName' Applied c
 pprParendType (PromotedTupleT 0)  = text "'()"
 pprParendType (PromotedTupleT n)  = quoteParens (hcat (replicate (n-1) comma))
 pprParendType PromotedNilT        = text "'[]"
-pprParendType PromotedConsT       = text "(':)"
+pprParendType PromotedConsT       = text "'(:)"
 pprParendType StarT               = char '*'
 pprParendType ConstraintT         = text "Constraint"
 pprParendType (SigT ty k)         = parens (ppr ty <+> text "::" <+> ppr k)
diff --git a/testsuite/tests/th/T13887.hs b/testsuite/tests/th/T13887.hs
new file mode 100644
index 0000000..8687447
--- /dev/null
+++ b/testsuite/tests/th/T13887.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE DataKinds #-}
+{-# LANGUAGE TemplateHaskell #-}
+module Main where
+
+import Data.Proxy
+import GHC.Generics
+import Language.Haskell.TH
+
+main :: IO ()
+main = do
+  putStrLn $([t| Proxy  (:*:) |] >>= stringE . pprint)
+  putStrLn $([t| Proxy '(:*:) |] >>= stringE . pprint)
+  putStrLn $([t| Proxy '(:)   |] >>= stringE . pprint)
diff --git a/testsuite/tests/th/T13887.stdout b/testsuite/tests/th/T13887.stdout
new file mode 100644
index 0000000..48845be
--- /dev/null
+++ b/testsuite/tests/th/T13887.stdout
@@ -0,0 +1,3 @@
+Data.Proxy.Proxy (GHC.Generics.:*:)
+Data.Proxy.Proxy '(GHC.Generics.:*:)
+Data.Proxy.Proxy '(GHC.Types.:)
diff --git a/testsuite/tests/th/TH_PromotedList.stderr b/testsuite/tests/th/TH_PromotedList.stderr
index 8a6422f..fde888f 100644
--- a/testsuite/tests/th/TH_PromotedList.stderr
+++ b/testsuite/tests/th/TH_PromotedList.stderr
@@ -1,3 +1,3 @@
 
-TH_PromotedList.hs:11:3: Warning:
-    (':) GHC.Types.Int ((':) GHC.Types.Bool '[])
+TH_PromotedList.hs:11:3: warning:
+    '(:) GHC.Types.Int ('(:) GHC.Types.Bool '[])
diff --git a/testsuite/tests/th/TH_RichKinds2.stderr b/testsuite/tests/th/TH_RichKinds2.stderr
index 1182929..6b06622 100644
--- a/testsuite/tests/th/TH_RichKinds2.stderr
+++ b/testsuite/tests/th/TH_RichKinds2.stderr
@@ -5,5 +5,6 @@ TH_RichKinds2.hs:24:4: warning:
     SJust_4 :: (s_5 a_6) -> SMaybe_0 s_5 ('GHC.Base.Just a_6)
 type instance TH_RichKinds2.Map f_7 '[] = '[]
 type instance TH_RichKinds2.Map f_8
-                                ('GHC.Types.: h_9 t_10) = 'GHC.Types.: (f_8 h_9)
-                                                                       (TH_RichKinds2.Map f_8 t_10)
+                                ('(GHC.Types.:) h_9 t_10) = '(GHC.Types.:) (f_8 h_9)
+                                                                           (TH_RichKinds2.Map f_8
+                                                                                              t_10)
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 3db9857..29a6334 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -391,4 +391,5 @@ test('T13781', normal, compile, ['-v0'])
 test('T13782', normal, compile, [''])
 test('T13837', normal, compile_fail, ['-v0 -dsuppress-uniques'])
 test('T13856', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques'])
+test('T13887', normal, compile_and_run, ['-v0'])
 test('T13968', normal, compile_fail, ['-v0'])



More information about the ghc-commits mailing list