diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-09-19 13:32:33 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-09-19 13:32:33 -0400 |
commit | 11fd1db04f22101a5a0fa8e1d5b57126e75f6eb5 (patch) | |
tree | f50a6fffa9a2e6aaacfe70b509015a14b90a0a16 /lib/ur | |
parent | e6166ff9bc4f189cadaf235672543890ef922d11 (diff) |
Grid sorting working
Diffstat (limited to 'lib/ur')
-rw-r--r-- | lib/ur/basis.urs | 1 | ||||
-rw-r--r-- | lib/ur/option.ur | 12 | ||||
-rw-r--r-- | lib/ur/option.urs | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 04404ad5..b7468d2f 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -49,6 +49,7 @@ val ord_string : ord string val ord_char : ord char val ord_bool : ord bool val ord_time : ord time +val mkOrd : t ::: Type -> {Lt : t -> t -> bool, Le : t -> t -> bool} -> ord t (** String operations *) diff --git a/lib/ur/option.ur b/lib/ur/option.ur index a22cf5b5..1ba33d8e 100644 --- a/lib/ur/option.ur +++ b/lib/ur/option.ur @@ -7,6 +7,18 @@ fun eq [a] (_ : eq a) = | (Some x, Some y) => x = y | _ => False) +fun ord [a] (_ : ord a) = + mkOrd {Lt = fn x y => + case (x, y) of + (None, Some _) => True + | (Some x, Some y) => x < y + | _ => False, + Le = fn x y => + case (x, y) of + (None, _) => True + | (Some x, Some y) => x <= y + | _ => False} + fun isNone [a] x = case x of None => True diff --git a/lib/ur/option.urs b/lib/ur/option.urs index f4570768..60ca6db9 100644 --- a/lib/ur/option.urs +++ b/lib/ur/option.urs @@ -1,6 +1,7 @@ datatype t = datatype Basis.option val eq : a ::: Type -> eq a -> eq (t a) +val ord : a ::: Type -> ord a -> ord (t a) val isNone : a ::: Type -> t a -> bool val isSome : a ::: Type -> t a -> bool |