summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Brown <greg.brown01@ed.ac.uk>2022-12-17 12:41:22 +0000
committerGreg Brown <greg.brown01@ed.ac.uk>2022-12-17 15:10:17 +0000
commit8281e2ea3e531196b8e26ea021ff417670b68bb8 (patch)
tree769eeff176da5889e4c89c3641a8b3f0e80dc5e4
parent8eddb5e439005a1abf73703d58bb1c7749ca5807 (diff)
Define raw syntax.
-rw-r--r--obs.ipkg1
-rw-r--r--src/Obs/Syntax.idr41
2 files changed, 42 insertions, 0 deletions
diff --git a/obs.ipkg b/obs.ipkg
index 229fbe6..3320896 100644
--- a/obs.ipkg
+++ b/obs.ipkg
@@ -6,3 +6,4 @@ depends = contrib
modules
= Obs.Sort
+ , Obs.Syntax
diff --git a/src/Obs/Syntax.idr b/src/Obs/Syntax.idr
new file mode 100644
index 0000000..9ec1d3d
--- /dev/null
+++ b/src/Obs/Syntax.idr
@@ -0,0 +1,41 @@
+||| Raw syntax for terms. This is before eliminating names.
+module Obs.Syntax
+
+import Obs.Sort
+import Text.Bounded
+import Text.PrettyPrint.Prettyprinter
+
+-- Definition ------------------------------------------------------------------
+
+public export
+data Syntax : Type where
+ Var : Bounds -> String -> Syntax
+ -- Sorts
+ Sort : Bounds -> Sort -> Syntax
+
+public export
+record Definition where
+ constructor MkDefinition
+ bounds : Bounds -- of the name
+ name : String
+ ty : Syntax
+ tm : Syntax
+
+-- Operations ------------------------------------------------------------------
+
+fullBounds : Syntax -> Bounds
+fullBounds (Var x str) = x
+fullBounds (Sort x s) = x
+
+-- Pretty Print ----------------------------------------------------------------
+
+export
+Pretty Syntax where
+ prettyPrec d (Var x str) = pretty str
+ prettyPrec d (Sort x s) = prettyPrec d s
+
+export
+Pretty Definition where
+ pretty def = group $
+ pretty def.name <++> colon <+> softline <+> pretty def.ty <+> hardline <+>
+ pretty def.name <++> equals <+> softline <+> pretty def.tm