| ... |
... |
@@ -1440,7 +1440,7 @@ ppr_mono_ty (HsSpliceTy ext s) = |
|
1440
|
1440
|
GhcRn | HsUntypedSpliceTop _ t <- ext -> ppr t
|
|
1441
|
1441
|
GhcTc -> pprUntypedSplice True Nothing s
|
|
1442
|
1442
|
ppr_mono_ty (HsExplicitListTy _ prom tys)
|
|
1443
|
|
- | isPromoted prom = quote $ brackets (maybeAddSpace tys $ interpp'SP tys)
|
|
|
1443
|
+ | isPromoted prom = quote $ brackets (spaceIfSingleQuote $ interpp'SP tys)
|
|
1444
|
1444
|
| otherwise = brackets (interpp'SP tys)
|
|
1445
|
1445
|
ppr_mono_ty (HsExplicitTupleTy _ prom tys)
|
|
1446
|
1446
|
-- Special-case unary boxed tuples so that they are pretty-printed as
|
| ... |
... |
@@ -1448,7 +1448,7 @@ ppr_mono_ty (HsExplicitTupleTy _ prom tys) |
|
1448
|
1448
|
| [ty] <- tys
|
|
1449
|
1449
|
= quote_tuple prom $ sep [text (mkTupleStr Boxed dataName 1), ppr_mono_lty ty]
|
|
1450
|
1450
|
| otherwise
|
|
1451
|
|
- = quote_tuple prom $ parens (maybeAddSpace tys $ interpp'SP tys)
|
|
|
1451
|
+ = quote_tuple prom $ parens (spaceIfSingleQuote $ interpp'SP tys)
|
|
1452
|
1452
|
ppr_mono_ty (HsTyLit _ t) = ppr t
|
|
1453
|
1453
|
ppr_mono_ty (HsWildCardTy {}) = char '_'
|
|
1454
|
1454
|
|
| ... |
... |
@@ -1547,45 +1547,6 @@ hsTypeNeedsParens p = go_hs_ty |
|
1547
|
1547
|
go_core_ty (CastTy t _) = go_core_ty t
|
|
1548
|
1548
|
go_core_ty (CoercionTy{}) = False
|
|
1549
|
1549
|
|
|
1550
|
|
-maybeAddSpace :: [LHsType (GhcPass p)] -> SDoc -> SDoc
|
|
1551
|
|
--- See Note [Printing promoted type constructors]
|
|
1552
|
|
--- in GHC.Iface.Type. This code implements the same
|
|
1553
|
|
--- logic for printing HsType
|
|
1554
|
|
-maybeAddSpace tys doc
|
|
1555
|
|
- | (ty : _) <- tys
|
|
1556
|
|
- , lhsTypeHasLeadingPromotionQuote ty = space <> doc
|
|
1557
|
|
- | otherwise = doc
|
|
1558
|
|
-
|
|
1559
|
|
-lhsTypeHasLeadingPromotionQuote :: LHsType (GhcPass p) -> Bool
|
|
1560
|
|
-lhsTypeHasLeadingPromotionQuote ty
|
|
1561
|
|
- = goL ty
|
|
1562
|
|
- where
|
|
1563
|
|
- goL (L _ ty) = go ty
|
|
1564
|
|
-
|
|
1565
|
|
- go (HsForAllTy{}) = False
|
|
1566
|
|
- go (HsQualTy{ hst_ctxt = ctxt, hst_body = body})
|
|
1567
|
|
- | (L _ (c:_)) <- ctxt = goL c
|
|
1568
|
|
- | otherwise = goL body
|
|
1569
|
|
- go (HsTyVar _ p _) = isPromoted p
|
|
1570
|
|
- go (HsFunTy _ _ arg _) = goL arg
|
|
1571
|
|
- go (HsListTy{}) = False
|
|
1572
|
|
- go (HsTupleTy{}) = False
|
|
1573
|
|
- go (HsSumTy{}) = False
|
|
1574
|
|
- go (HsOpTy _ _ t1 _ _) = goL t1
|
|
1575
|
|
- go (HsKindSig _ t _) = goL t
|
|
1576
|
|
- go (HsIParamTy{}) = False
|
|
1577
|
|
- go (HsSpliceTy{}) = False
|
|
1578
|
|
- go (HsExplicitListTy _ p _) = isPromoted p
|
|
1579
|
|
- go (HsExplicitTupleTy{}) = True
|
|
1580
|
|
- go (HsTyLit{}) = False
|
|
1581
|
|
- go (HsWildCardTy{}) = False
|
|
1582
|
|
- go (HsStarTy{}) = False
|
|
1583
|
|
- go (HsAppTy _ t _) = goL t
|
|
1584
|
|
- go (HsAppKindTy _ t _) = goL t
|
|
1585
|
|
- go (HsParTy{}) = False
|
|
1586
|
|
- go (HsDocTy _ t _) = goL t
|
|
1587
|
|
- go (XHsType{}) = False
|
|
1588
|
|
-
|
|
1589
|
1550
|
-- | @'parenthesizeHsType' p ty@ checks if @'hsTypeNeedsParens' p ty@ is
|
|
1590
|
1551
|
-- true, and if so, surrounds @ty@ with an 'HsParTy'. Otherwise, it simply
|
|
1591
|
1552
|
-- returns @ty@.
|