print non-dependent products (easy mode)
only if the AST uses SN, like with Eq
This commit is contained in:
parent
958bc2f8b8
commit
ea24d00544
5 changed files with 39 additions and 19 deletions
|
@ -224,10 +224,14 @@ mutual
|
||||||
private covering
|
private covering
|
||||||
infixEqTerm : Grammar True PTerm
|
infixEqTerm : Grammar True PTerm
|
||||||
infixEqTerm = do
|
infixEqTerm = do
|
||||||
l <- appTerm
|
l <- infixTimesTerm
|
||||||
rty <- optional [|MkPair (resC "≡" *> term) (resC ":" *> appTerm)|]
|
rty <- optional [|MkPair (resC "≡" *> term) (resC ":" *> infixTimesTerm)|]
|
||||||
pure $ maybe l (\rty => Eq (Nothing, snd rty) l (fst rty)) rty
|
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
|
private covering
|
||||||
appTerm : Grammar True PTerm
|
appTerm : Grammar True PTerm
|
||||||
appTerm = resC "★" *> [|TYPE nat|]
|
appTerm = resC "★" *> [|TYPE nat|]
|
||||||
|
|
|
@ -42,10 +42,12 @@ data HL
|
||||||
public export
|
public export
|
||||||
data PPrec
|
data PPrec
|
||||||
= Outer
|
= Outer
|
||||||
| Ann -- right of "∷"
|
| AnnR -- right of "∷"
|
||||||
| AnnL -- left of "∷"
|
| AnnL -- left of "∷"
|
||||||
| Eq -- "_ ≡ _ : _"
|
| Eq -- "_ ≡ _ : _"
|
||||||
| InEq -- arguments of ≡
|
| InEq -- arguments of ≡
|
||||||
|
| Times -- "_ × _"
|
||||||
|
| InTimes -- arguments of ×
|
||||||
-- ...
|
-- ...
|
||||||
| App -- term/dimension application
|
| App -- term/dimension application
|
||||||
| SApp -- substitution application
|
| SApp -- substitution application
|
||||||
|
|
|
@ -61,8 +61,8 @@ prettyBindType : PrettyHL a => PrettyHL b => PrettyHL q =>
|
||||||
List q -> BaseName -> a -> Doc HL -> b -> m (Doc HL)
|
List q -> BaseName -> a -> Doc HL -> b -> m (Doc HL)
|
||||||
prettyBindType qtys x s arr t = do
|
prettyBindType qtys x s arr t = do
|
||||||
bind <- prettyBind qtys x s
|
bind <- prettyBind qtys x s
|
||||||
t <- withPrec Outer $ under T x $ prettyM t
|
t <- withPrec AnnR $ under T x $ prettyM t
|
||||||
parensIfM Outer $ hang 2 $ parens bind <++> arr <%%> t
|
parensIfM AnnR $ hang 2 $ parens bind <++> arr <%%> t
|
||||||
|
|
||||||
export
|
export
|
||||||
prettyArm : PrettyHL a => Pretty.HasEnv m =>
|
prettyArm : PrettyHL a => Pretty.HasEnv m =>
|
||||||
|
@ -151,8 +151,12 @@ parameters (showSubsts : Bool)
|
||||||
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
|
||||||
prettyM (Sig s (S [< x] t)) =
|
prettyM (Sig s (S _ (N t))) = do
|
||||||
prettyBindType {q} [] x s !timesD t.term
|
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) =
|
prettyM (Pair s t) =
|
||||||
let GotPairs {init, last, _} = getPairs' [< s] t in
|
let GotPairs {init, last, _} = getPairs' [< s] t in
|
||||||
prettyTuple $ toList $ init :< last
|
prettyTuple $ toList $ init :< last
|
||||||
|
@ -209,8 +213,8 @@ parameters (showSubsts : Bool)
|
||||||
prettyApps (Just "@") fun args
|
prettyApps (Just "@") fun args
|
||||||
prettyM (s :# a) = do
|
prettyM (s :# a) = do
|
||||||
s <- withPrec AnnL $ prettyM s
|
s <- withPrec AnnL $ prettyM s
|
||||||
a <- withPrec Ann $ prettyM a
|
a <- withPrec AnnR $ prettyM a
|
||||||
parensIfM Ann $ hang 2 $ s <++> !annD <%%> a
|
parensIfM AnnR $ hang 2 $ s <++> !annD <%%> a
|
||||||
prettyM (CloE e th) =
|
prettyM (CloE e th) =
|
||||||
if showSubsts then
|
if showSubsts then
|
||||||
parensIfM SApp . hang 2 =<<
|
parensIfM SApp . hang 2 =<<
|
||||||
|
|
|
@ -156,7 +156,15 @@ tests = "parser" :- [
|
||||||
Sig (Just "x") (V "A") (V "B" :@ V "x"),
|
Sig (Just "x") (V "A") (V "B" :@ V "x"),
|
||||||
parsesAs term "(x : A) ** B x" $
|
parsesAs term "(x : A) ** B x" $
|
||||||
Sig (Just "x") (V "A") (V "B" :@ V "x"),
|
Sig (Just "x") (V "A") (V "B" :@ V "x"),
|
||||||
parseFails term "(1.x : A) × B x"
|
parseFails term "(1.x : A) × B x",
|
||||||
|
parsesAs term "A × B" $
|
||||||
|
Sig Nothing (V "A") (V "B"),
|
||||||
|
parsesAs term "A ** B" $
|
||||||
|
Sig Nothing (V "A") (V "B"),
|
||||||
|
parsesAs term "A × B × C" $
|
||||||
|
Sig Nothing (V "A") (Sig Nothing (V "B") (V "C")),
|
||||||
|
parsesAs term "(A × B) × C" $
|
||||||
|
Sig Nothing (Sig Nothing (V "A") (V "B")) (V "C")
|
||||||
],
|
],
|
||||||
|
|
||||||
"lambdas" :- [
|
"lambdas" :- [
|
||||||
|
@ -205,6 +213,9 @@ tests = "parser" :- [
|
||||||
parsesAs term "f x y ≡ g y z : A B C" $
|
parsesAs term "f x y ≡ g y z : A B C" $
|
||||||
Eq (Nothing, V "A" :@ V "B" :@ V "C")
|
Eq (Nothing, V "A" :@ V "B" :@ V "C")
|
||||||
(V "f" :@ V "x" :@ V "y") (V "g" :@ V "y" :@ V "z"),
|
(V "f" :@ V "x" :@ V "y") (V "g" :@ V "y" :@ V "z"),
|
||||||
|
parsesAs term "A × B ≡ A' × B' : ★₁" $
|
||||||
|
Eq (Nothing, TYPE 1)
|
||||||
|
(Sig Nothing (V "A") (V "B")) (Sig Nothing (V "A'") (V "B'")),
|
||||||
parseFails term "Eq",
|
parseFails term "Eq",
|
||||||
parseFails term "Eq s t",
|
parseFails term "Eq s t",
|
||||||
parseFails term "s ≡ t",
|
parseFails term "s ≡ t",
|
||||||
|
@ -242,19 +253,19 @@ tests = "parser" :- [
|
||||||
],
|
],
|
||||||
|
|
||||||
"definitions" :- [
|
"definitions" :- [
|
||||||
parsesAs definition "defω x : (_: {a}) × {b} = ('a, 'b)" $
|
parsesAs definition "defω x : {a} × {b} = ('a, 'b)" $
|
||||||
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
||||||
(Pair (Tag "a") (Tag "b")),
|
(Pair (Tag "a") (Tag "b")),
|
||||||
parsesAs definition "defω x : (_: {a}) × {b} = ('a, 'b)" $
|
parsesAs definition "defω x : {a} × {b} = ('a, 'b)" $
|
||||||
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
||||||
(Pair (Tag "a") (Tag "b")),
|
(Pair (Tag "a") (Tag "b")),
|
||||||
parsesAs definition "def# x : (_: {a}) ** {b} = ('a, 'b)" $
|
parsesAs definition "def# x : {a} ** {b} = ('a, 'b)" $
|
||||||
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
||||||
(Pair (Tag "a") (Tag "b")),
|
(Pair (Tag "a") (Tag "b")),
|
||||||
parsesAs definition "def ω.x : (_: {a}) × {b} = ('a, 'b)" $
|
parsesAs definition "def ω.x : {a} × {b} = ('a, 'b)" $
|
||||||
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
||||||
(Pair (Tag "a") (Tag "b")),
|
(Pair (Tag "a") (Tag "b")),
|
||||||
parsesAs definition "def x : (_: {a}) × {b} = ('a, 'b)" $
|
parsesAs definition "def x : {a} × {b} = ('a, 'b)" $
|
||||||
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
MkPDef Any "x" (Just $ Sig Nothing (Enum ["a"]) (Enum ["b"]))
|
||||||
(Pair (Tag "a") (Tag "b")),
|
(Pair (Tag "a") (Tag "b")),
|
||||||
parsesAs definition "def0 A : ★₀ = {a, b, c}" $
|
parsesAs definition "def0 A : ★₀ = {a, b, c}" $
|
||||||
|
|
|
@ -108,7 +108,6 @@ tests = "pretty printing terms" :- [
|
||||||
],
|
],
|
||||||
|
|
||||||
"pair types" :- [
|
"pair types" :- [
|
||||||
skipWith "todo: non-dependent notation" $
|
|
||||||
testPrettyT [<] [<] (FT "A" `And` FT "B") "A × B" "A ** B",
|
testPrettyT [<] [<] (FT "A" `And` FT "B") "A × B" "A ** B",
|
||||||
testPrettyT [<] [<]
|
testPrettyT [<] [<]
|
||||||
(Sig_ "x" (FT "A") (E $ F "B" :@ BVT 0))
|
(Sig_ "x" (FT "A") (E $ F "B" :@ BVT 0))
|
||||||
|
|
Loading…
Reference in a new issue