diff options
author | Greg Brown <greg.brown01@ed.ac.uk> | 2022-12-17 10:26:37 +0000 |
---|---|---|
committer | Greg Brown <greg.brown01@ed.ac.uk> | 2022-12-17 10:41:24 +0000 |
commit | 29c2714d5b5eddf053579d66d20c88daa7cd4859 (patch) | |
tree | 771025814d33073dbe9a95b7caab615bdf4d4a1d /src/Obs/Sort.idr | |
parent | 4fa5948dafdb102ad0ab1cd3753d910929534673 (diff) |
Define sorts.
Diffstat (limited to 'src/Obs/Sort.idr')
-rw-r--r-- | src/Obs/Sort.idr | 44 |
1 files changed, 44 insertions, 0 deletions
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) |