summaryrefslogtreecommitdiff
path: root/src/Obs/Syntax.idr
diff options
context:
space:
mode:
authorGreg Brown <greg.brown01@ed.ac.uk>2022-12-18 22:56:48 +0000
committerGreg Brown <greg.brown01@ed.ac.uk>2022-12-18 22:56:48 +0000
commit49e4b61cd6b8150e516997606e803bfeec75d1f0 (patch)
treebe6fcbb3d1e5dd7e33a100bf364878157616c550 /src/Obs/Syntax.idr
parent9452d3aee15b8943684828320324b3da37efb397 (diff)
Add dependent sums.
Diffstat (limited to 'src/Obs/Syntax.idr')
-rw-r--r--src/Obs/Syntax.idr25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/Obs/Syntax.idr b/src/Obs/Syntax.idr
index 4a7ee0c..f1a552f 100644
--- a/src/Obs/Syntax.idr
+++ b/src/Obs/Syntax.idr
@@ -18,6 +18,11 @@ data Syntax : Type where
Pi : Bounds -> WithBounds String -> Syntax -> Syntax -> Syntax
Lambda : Bounds -> WithBounds String -> Syntax -> Syntax
App : Syntax -> Syntax -> Syntax
+ -- Dependent Sums
+ Sigma : Bounds -> WithBounds String -> Syntax -> Syntax -> Syntax
+ Pair : Bounds -> Syntax -> Syntax -> Syntax
+ Fst : Bounds -> Syntax -> Syntax
+ Snd : Bounds -> Syntax -> Syntax
-- True
Top : Bounds -> Syntax
Point : Bounds -> Syntax
@@ -55,8 +60,26 @@ Pretty Syntax where
parenthesise (d >= App) $
group $
fillSep [prettyPrec Open t, prettyPrec App u]
+ prettyPrec d (Sigma _ var a b) =
+ parenthesise (d >= App) $
+ group $
+ parens (pretty var.val <++> colon <+> softline <+> prettyPrec Open a) <++>
+ pretty "**" <+> softline <+>
+ prettyPrec Open b
+ prettyPrec d (Pair _ t u) =
+ angles $
+ group $
+ neutral <++> prettyPrec Open t <+> comma <+> softline <+> prettyPrec Open u <++> neutral
+ prettyPrec d (Fst _ t) =
+ parenthesise (d >= App) $
+ group $
+ fillSep [pretty "fst", prettyPrec App t]
+ prettyPrec d (Snd _ t) =
+ parenthesise (d >= App) $
+ group $
+ fillSep [pretty "snd", prettyPrec App t]
prettyPrec d (Top _) = pretty "()"
- prettyPrec d (Point _) = pretty "*"
+ prettyPrec d (Point _) = pretty "tt"
prettyPrec d (Bottom _) = pretty "Void"
prettyPrec d (Absurd _ a t) =
parenthesise (d >= App) $