print non-dependent function types as "π.A → B"

This commit is contained in:
rhiannon morris 2023-03-18 23:32:53 +01:00
parent 8f0f0c1891
commit 443da20c4b
2 changed files with 16 additions and 12 deletions

View file

@ -165,8 +165,12 @@ parameters (showSubsts : Bool)
where where
prettyM (TYPE l) = prettyM (TYPE l) =
parensIfM App $ !typeD <+> hl Syntax !(prettyUnivSuffix l) parensIfM App $ !typeD <+> hl Syntax !(prettyUnivSuffix l)
prettyM (Pi qty s (S [< x] t)) = prettyM (Pi qty s (S _ (N t))) = do
prettyBindType (Just qty) x s !arrowD t.term dom <- pretty0M $ MkWithQty qty s
cod <- withPrec AnnR $ prettyM t
parensIfM AnnR $ asep [dom <++> !arrowD, cod]
prettyM (Pi qty s (S [< x] (Y t))) =
prettyBindType (Just qty) x s !arrowD t
prettyM (Lam (S x t)) = prettyM (Lam (S x t)) =
let GotLams {names, body, _} = getLams' x t.term Refl in let GotLams {names, body, _} = getLams' x t.term Refl in
prettyLams (Just !lamD) T (toSnocList' names) body prettyLams (Just !lamD) T (toSnocList' names) body

View file

@ -97,13 +97,13 @@ tests = "pretty printing terms" :- [
"1.(x : A) -> B x", "1.(x : A) -> B x",
testPrettyT [<] [<] testPrettyT [<] [<]
(Pi_ Zero "A" (TYPE 0) $ Arr Any (BVT 0) (BVT 0)) (Pi_ Zero "A" (TYPE 0) $ Arr Any (BVT 0) (BVT 0))
"0.(A : ★₀) → ω.(_ : A) → A" "0.(A : ★₀) → ω.A → A"
"0.(A : Type0) -> #.(_ : A) -> A", "0.(A : Type0) -> #.A -> A",
todo #"print (and parse) the below as "(AA)A""#, todo #"print (and parse) the below as "(AA)A""#,
testPrettyT [<] [<] testPrettyT [<] [<]
(Arr Any (Arr Any (FT "A") (FT "A")) (FT "A")) (Arr Any (Arr Any (FT "A") (FT "A")) (FT "A"))
"ω.(_ : ω.(_ : A) → A) → A" "ω.(ω.A → A) → A"
"#.(_ : #.(_ : A) -> A) -> A", "#.(#.A -> A) -> A",
todo "non-dependent, left and right nested" todo "non-dependent, left and right nested"
], ],
@ -128,8 +128,8 @@ tests = "pretty printing terms" :- [
testPrettyT1 [<] [<] (Pair (Pair (FT "A") (FT "B")) (FT "C")) "((A, B), C)", testPrettyT1 [<] [<] (Pair (Pair (FT "A") (FT "B")) (FT "C")) "((A, B), C)",
testPrettyT [<] [<] testPrettyT [<] [<]
(Pair ([< "x"] :\\ BVT 0) (Arr One (FT "B₁") (FT "B₂"))) (Pair ([< "x"] :\\ BVT 0) (Arr One (FT "B₁") (FT "B₂")))
"(λ x ⇒ x, 1.(_ : B₁) → B₂)" "(λ x ⇒ x, 1.B₁ → B₂)"
"(fun x => x, 1.(_ : B₁) -> B₂)" "(fun x => x, 1.B₁ -> B₂)"
], ],
"enum types" :- [ "enum types" :- [
@ -180,11 +180,11 @@ tests = "pretty printing terms" :- [
"(α :: a) :: A", "(α :: a) :: A",
testPrettyE [<] [<] testPrettyE [<] [<]
(([< "x"] :\\ BVT 0) :# Arr One (FT "A") (FT "A")) (([< "x"] :\\ BVT 0) :# Arr One (FT "A") (FT "A"))
"(λ x ⇒ x) ∷ 1.(_ : A) → A" "(λ x ⇒ x) ∷ 1.A → A"
"(fun x => x) :: 1.(_ : A) -> A", "(fun x => x) :: 1.A -> A",
testPrettyE [<] [<] testPrettyE [<] [<]
(Arr One (FT "A") (FT "A") :# TYPE 7) (Arr One (FT "A") (FT "A") :# TYPE 7)
"(1.(_ : A) → A) ∷ ★₇" "(1.A → A) ∷ ★₇"
"(1.(_ : A) -> A) :: Type7" "(1.A -> A) :: Type7"
] ]
] ]