pprint universes as a direct suffix

in subscript in unicode mode
This commit is contained in:
rhiannon morris 2023-02-26 11:20:06 +01:00
parent fbfbe57266
commit 82a2f92ddf
2 changed files with 12 additions and 1 deletions

View File

@ -94,7 +94,7 @@ mutual
export covering
PrettyHL q => PrettyHL (Term q d n) where
prettyM (TYPE l) =
parensIfM App $ !typeD <//> !(withPrec Arg $ prettyM l)
parensIfM App $ !typeD <+> hl Syntax !(prettyUnivSuffix l)
prettyM (Pi qty s (S [x] t)) =
prettyBindType [qty] x s !arrowD t
prettyM (Lam (S x t)) =

View File

@ -22,6 +22,17 @@ PrettyHL Universe where
prettyM UAny = pure $ hl Delim "_"
prettyM (U l) = pure $ hl Free $ pretty l
export
prettyUnivSuffix : Pretty.HasEnv m => Universe -> m (Doc HL)
prettyUnivSuffix UAny = ifUnicode "_" ""
prettyUnivSuffix (U l) =
ifUnicode (pretty $ pack $ map sub $ unpack $ show l) (pretty l)
where
sub : Char -> Char
sub c = case c of
'0' => ''; '1' => ''; '2' => ''; '3' => ''; '4' => ''
'5' => ''; '6' => ''; '7' => ''; '8' => ''; '9' => ''; _ => c
export %inline
fromInteger : (x : Integer) -> (0 _ : So (x >= 0)) => Universe
fromInteger x = U $ fromInteger x