diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-07-29 19:36:42 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2017-07-29 19:36:42 -0400 |
commit | 7089dc2f12f9616771fc1de143e9b974157405d8 (patch) | |
tree | 386a5bebf509ffb04ef8b91a34d1214e59bee441 | |
parent | f839b9de18a9f795e438314bea9f17e594afa354 (diff) | |
download | haskell-7089dc2f12f9616771fc1de143e9b974157405d8.tar.gz |
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
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Ppr.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/th/T13887.hs | 13 | ||||
-rw-r--r-- | testsuite/tests/th/T13887.stdout | 3 | ||||
-rw-r--r-- | testsuite/tests/th/TH_PromotedList.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/th/TH_RichKinds2.stderr | 5 | ||||
-rw-r--r-- | 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 696c4454c7..e6c33029ab 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 0000000000..8687447d16 --- /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 0000000000..48845be60a --- /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 8a6422f6ec..fde888ff88 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 11829296e0..6b0662218a 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 3db985777c..29a6334f6b 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']) |