summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Brown <greg.brown01@ed.ac.uk>2022-12-17 10:26:37 +0000
committerGreg Brown <greg.brown01@ed.ac.uk>2022-12-17 10:41:24 +0000
commit29c2714d5b5eddf053579d66d20c88daa7cd4859 (patch)
tree771025814d33073dbe9a95b7caab615bdf4d4a1d
parent4fa5948dafdb102ad0ab1cd3753d910929534673 (diff)
Define sorts.
-rw-r--r--obs.ipkg3
-rw-r--r--src/Obs.idr0
-rw-r--r--src/Obs/Sort.idr44
3 files changed, 46 insertions, 1 deletions
diff --git a/obs.ipkg b/obs.ipkg
index 4a5cafc..f556fef 100644
--- a/obs.ipkg
+++ b/obs.ipkg
@@ -2,4 +2,5 @@ package obs
authors = "Greg Brown"
sourcedir = "src"
-modules = Obs
+modules
+ = Obs.Sort
diff --git a/src/Obs.idr b/src/Obs.idr
deleted file mode 100644
index e69de29..0000000
--- a/src/Obs.idr
+++ /dev/null
diff --git a/src/Obs/Sort.idr b/src/Obs/Sort.idr
new file mode 100644
index 0000000..16eaa96
--- /dev/null
+++ b/src/Obs/Sort.idr
@@ -0,0 +1,44 @@
+module Obs.Sort
+
+-- Definition ------------------------------------------------------------------
+
+public export
+data Sort : Type where
+ Prop : Sort
+ Set : Nat -> Sort
+
+%name Sort s, s', s'', s'''
+
+-- Interfaces ------------------------------------------------------------------
+
+export
+Eq Sort where
+ Prop == Prop = True
+ (Set i) == (Set j) = True
+ _ == _ = False
+
+export
+Show Sort where
+ show Prop = "Prop"
+ show (Set 0) = "Set"
+ show (Set (S i)) = "Set \{show (S i)}"
+
+-- Operations ------------------------------------------------------------------
+
+infix 5 ~>
+
+public export
+suc : Sort -> Sort
+suc Prop = Set 0
+suc (Set i) = Set (S i)
+
+public export
+lub : Sort -> Sort -> Sort
+lub Prop s' = s'
+lub (Set i) Prop = Set i
+lub (Set i) (Set j) = Set (max i j)
+
+public export
+(~>) : Sort -> Sort -> Sort
+s ~> Prop = Prop
+s ~> (Set k) = lub s (Set k)