@@ -1820,20 +1820,35 @@ pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
18201820 TypeOrTerm -> id
18211821 IsType -> annName pairTy
18221822 IsTerm -> annName pairCon
1823− prettySe d p bnd (PDPair _ _ pun l t r) =
1824− depth d $
1825− annotated lparen <>
1826− left <+>
1827− annotated (text "**") <+>
1828− prettySe (decD d) startPrec (addBinding bnd) r <>
1829− annotated rparen
1823+ prettySe d p bnd dpair@(PDPair _ _ pun l t r)
1824+ | Just elts <- dPairElts dpair
1825+ = depth d . enclose (annotated lparen) (annotated rparen) .
1826+ align . group . vsep . punctuate (space <> annotated (text "**")) $
1827+ ppElts elts bnd
1828+ | otherwise
1829+ = depth d $
1830+ annotated lparen <>
1831+ left <+>
1832+ annotated (text "**") <+>
1833+ prettySe (decD d) startPrec (addBinding bnd) r <>
1834+ annotated rparen
18301835 where annotated = case pun of
18311836 IsType -> annName sigmaTy
18321837 IsTerm -> annName sigmaCon
18331838 TypeOrTerm -> id
1839+
18341840 (left, addBinding) = case (l, pun) of
18351841 (PRef _ _ n, IsType) -> (bindingOf n False <+> text ":" <+> prettySe (decD d) startPrec bnd t, ((n, False) :))
18361842 _ -> (prettySe (decD d) startPrec bnd l, id)
1843+
1844+ ppElts [] bs = []
1845+ ppElts [(_, v)] bs = [prettySe (decD d) startPrec bs v]
1846+ ppElts ((PRef _ _ n, t):rs) bs
1847+ | IsType <- pun
1848+ = (bindingOf n False <+> colon <+>
1849+ prettySe (decD d) startPrec bs t) : ppElts rs ((n, False):bs)
1850+ ppElts ((l, t):rs) bs
1851+ = (prettySe (decD d) startPrec bs l) : ppElts rs bs
18371852 prettySe d p bnd (PAlternative ns a as) =
18381853 lparen <> text "|" <> prettyAs <> text "|" <> rparen
18391854 where
@@ -1951,6 +1966,11 @@ pprintPTerm ppo bnd docArgs infixes = prettySe (ppopt_depth ppo) startPrec bnd
19511966 | otherwise = Just [x, y]
19521967 pairElts _ = Nothing
19531968
1969+ dPairElts :: PTerm -> Maybe [(PTerm, PTerm)]
1970+ dPairElts (PDPair _ _ _ l t r) | Just elts <- dPairElts r = Just ((l, t):elts)
1971+ | otherwise = Just [(l, t), (Placeholder, r)]
1972+ dPairElts _ = Nothing
1973+
19541974 natns = "Prelude.Nat."
19551975
19561976 snat :: PPOption -> Maybe Int -> Int -> PTerm -> Maybe Integer