term printing tweaks

This commit is contained in:
Paul Chiusano 2018-11-12 12:04:42 -05:00
parent 58e8f928c2
commit ca1f9d69a9
2 changed files with 5 additions and 2 deletions

View File

@ -114,7 +114,10 @@ pickName r h = case argmax snd (Map.toList h) of
pickNameReferent :: Referent -> Histogram -> Name
pickNameReferent r h = case argmax snd (Map.toList h) of
Nothing -> Text.pack (show r)
Nothing -> case r of
Names.Ref r -> Text.pack (show r)
Names.Con r i -> Text.pack (show r <> "#" <> show i)
Names.Req r i -> Text.pack (show r <> "#" <> show i)
Just (name,_) -> name
pickNameCid :: Reference -> Int -> Histogram -> Name

View File

@ -112,7 +112,7 @@ pretty n p term = specialCases term $ \case
<> PP.Nest " " (PP.Group (pretty n 2 body))
App' x (Constructor' Type.UnitRef 0) -> paren (p >= 11) $ l"!" <> pretty n 11 x
LamNamed' v x | (Var.name v) == "()" -> paren (p >= 11) $ l"'" <> pretty n 11 x
Vector' xs -> PP.Nest " " $ PP.Group $ l"[" <> commaList (toList xs) <> l"]"
Vector' xs -> PP.Group $ l"[" <> intercalateMap ("," <> b" ") (PP.Nest " " . pretty n 0) (toList xs) <> l"]"
If' cond t f -> parenNest (p >= 2) $
(PP.Group (l"if" <> b" " <> pretty n 2 cond) <> b" " <>
PP.Group (l"then" <> b" " <> pretty n 2 t) <> b" " <>