@@ -1364,12 +1364,28 @@ pprintPTerm ppo bnd docArgs infixes = prettySe 10 bnd
13641364 else if null args
13651365 then fp
13661366 else fp <+> align (vsep (map (prettyArgS bnd) args))
1367− prettySe p bnd (PCase _ scr opts) =
1368− kwd "case" <+> prettySe 10 bnd scr <+> kwd "of" <> prettyBody
1367+ prettySe p bnd (PCase _ scr cases) =
1368+ align $ kwd "case" <+> prettySe 10 bnd scr <+> kwd "of" <$>
1369+ indent 2 (vsep (map ppcase cases))
13691370 where
1370− prettyBody = foldr (<>) empty $ intersperse (text "|") $ map sc opts
1371+ ppcase (l, r) = nest nestingSize $
1372+ prettySe 10 ([(n, False) | n <- vars l] ++ bnd) l <+>
1373+ text "=>" <+>
1374+ prettySe 10 ([(n, False) | n <- vars l] ++ bnd) r
1375+ -- Warning: this is a bit of a hack. At this stage, we don't have the
1376+ -- global context, so we can't determine which names are constructors,
1377+ -- which are types, and which are pattern variables on the LHS of the
1378+ -- case pattern. We use the heuristic that names without a namespace
1379+ -- are patvars, because right now case blocks in PTerms are always
1380+ -- delaborated from TT before being sent to the pretty-printer. If they
1381+ -- start getting printed directly, THIS WILL BREAK.
1382+ -- Potential solution: add a list of known patvars to the cases in
1383+ -- PCase, and have the delaborator fill it out, kind of like the pun
1384+ -- disambiguation on PDPair.
1385+ vars tm = filter noNS (allNamesIn tm)
1386+ noNS (NS _ _) = False
1387+ noNS _ = True
13711388
1372− sc (l, r) = nest nestingSize $ prettySe 10 bnd l <+> text "=>" <+> prettySe 10 bnd r
13731389 prettySe p bnd (PHidden tm) = text "." <> prettySe 0 bnd tm
13741390 prettySe p bnd (PRefl _ _) = annName eqCon $ text "Refl"
13751391 prettySe p bnd (PResolveTC _) = text "resolvetc"
@@ -1538,13 +1554,15 @@ prettyName
15381554 -> [(Name, Bool)] -- ^^ the current bound variables and whether they are implicit
15391555 -> Name -- ^^ the name to pprint
15401556 -> Doc OutputAnnotation
1541−prettyName infixParen showNS bnd n
1557+prettyName infixParen showNS bnd n
1558+ | (MN _ s) <- n, isPrefixOf "_" $ T.unpack s = text "_"
1559+ | (UN n') <- n, isPrefixOf "_" $ T.unpack n' = text "_"
15421560 | Just imp <- lookup n bnd = annotate (AnnBoundName n imp) fullName
15431561 | otherwise = annotate (AnnName n Nothing Nothing Nothing) fullName
15441562 where fullName = text nameSpace <> parenthesise (text (baseName n))
15451563 baseName (UN n) = T.unpack n
15461564 baseName (NS n ns) = baseName n
1547− baseName (MN i s) = T.unpack s
1565+ baseName (MN i s) = T.unpack s
15481566 baseName other = show other
15491567 nameSpace = case n of
15501568 (NS n' ns) -> if showNS then (concatMap (++ ".") . map T.unpack . reverse) ns else ""