print non-dependent products (easy mode)

only if the AST uses SN, like with Eq
This commit is contained in:
rhiannon morris 2023-03-18 02:46:19 +01:00
parent 958bc2f8b8
commit ea24d00544
5 changed files with 39 additions and 19 deletions

View file

@ -224,10 +224,14 @@ mutual
private covering
infixEqTerm : Grammar True PTerm
infixEqTerm = do
l <- appTerm
rty <- optional [|MkPair (resC "" *> term) (resC ":" *> appTerm)|]
l <- infixTimesTerm
rty <- optional [|MkPair (resC "" *> term) (resC ":" *> infixTimesTerm)|]
pure $ maybe l (\rty => Eq (Nothing, snd rty) l (fst rty)) rty
private covering
infixTimesTerm : Grammar True PTerm
infixTimesTerm = foldr1 (Sig Nothing) <$> sepBy1 (resC "×") appTerm
private covering
appTerm : Grammar True PTerm
appTerm = resC "" *> [|TYPE nat|]

View file

@ -42,10 +42,12 @@ data HL
public export
data PPrec
= Outer
| Ann -- right of "∷"
| AnnL -- left of "∷"
| Eq -- "_ ≡ _ : _"
| InEq -- arguments of ≡
| AnnR -- right of "∷"
| AnnL -- left of "∷"
| Eq -- "_ ≡ _ : _"
| InEq -- arguments of ≡
| Times -- "_ × _"
| InTimes -- arguments of ×
-- ...
| App -- term/dimension application
| SApp -- substitution application

View file

@ -61,8 +61,8 @@ prettyBindType : PrettyHL a => PrettyHL b => PrettyHL q =>
List q -> BaseName -> a -> Doc HL -> b -> m (Doc HL)
prettyBindType qtys x s arr t = do
bind <- prettyBind qtys x s
t <- withPrec Outer $ under T x $ prettyM t
parensIfM Outer $ hang 2 $ parens bind <++> arr <%%> t
t <- withPrec AnnR $ under T x $ prettyM t
parensIfM AnnR $ hang 2 $ parens bind <++> arr <%%> t
export
prettyArm : PrettyHL a => Pretty.HasEnv m =>
@ -151,8 +151,12 @@ parameters (showSubsts : Bool)
prettyM (Lam (S x t)) =
let GotLams {names, body, _} = getLams' x t.term Refl in
prettyLams (Just !lamD) T (toSnocList' names) body
prettyM (Sig s (S [< x] t)) =
prettyBindType {q} [] x s !timesD t.term
prettyM (Sig s (S _ (N t))) = do
s <- withPrec InTimes $ prettyM s
t <- withPrec Times $ prettyM t
parensIfM Times $ asep [s <++> !timesD, t]
prettyM (Sig s (S [< x] (Y t))) =
prettyBindType {q} [] x s !timesD t
prettyM (Pair s t) =
let GotPairs {init, last, _} = getPairs' [< s] t in
prettyTuple $ toList $ init :< last
@ -209,8 +213,8 @@ parameters (showSubsts : Bool)
prettyApps (Just "@") fun args
prettyM (s :# a) = do
s <- withPrec AnnL $ prettyM s
a <- withPrec Ann $ prettyM a
parensIfM Ann $ hang 2 $ s <++> !annD <%%> a
a <- withPrec AnnR $ prettyM a
parensIfM AnnR $ hang 2 $ s <++> !annD <%%> a
prettyM (CloE e th) =
if showSubsts then
parensIfM SApp . hang 2 =<<