Commit 7089dc2f authored by Ryan Scott's avatar Ryan Scott

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
parent f839b9de
......@@ -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)
......
{-# 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)
Data.Proxy.Proxy (GHC.Generics.:*:)
Data.Proxy.Proxy '(GHC.Generics.:*:)
Data.Proxy.Proxy '(GHC.Types.:)
TH_PromotedList.hs:11:3: Warning:
(':) GHC.Types.Int ((':) GHC.Types.Bool '[])
TH_PromotedList.hs:11:3: warning:
'(:) GHC.Types.Int ('(:) GHC.Types.Bool '[])
......@@ -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)
......@@ -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'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment