changeset 394:9f6fe6f32961

ord_float and ord_bool
author Adam Chlipala <adamc@hcoop.net>
date Tue, 21 Oct 2008 11:19:17 -0400
parents bc5a56ed0cd6
children 9f67aac13cf7
files lib/basis.urs src/monoize.sml tests/ord.ur
diffstat 3 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/basis.urs	Tue Oct 21 11:13:03 2008 -0400
+++ b/lib/basis.urs	Tue Oct 21 11:19:17 2008 -0400
@@ -15,6 +15,7 @@
 val eq : t ::: Type -> eq t -> t -> t -> bool
 val ne : t ::: Type -> eq t -> t -> t -> bool
 val eq_int : eq int
+val eq_float : eq float
 val eq_string : eq string
 val eq_bool : eq bool
 
@@ -34,6 +35,9 @@
 val gt : t ::: Type -> ord t -> t -> t -> bool
 val ge : t ::: Type -> ord t -> t -> t -> bool
 val ord_int : ord int
+val ord_float : ord float
+val ord_string : ord string
+val ord_bool : ord bool
 
 
 (** String operations *)
--- a/src/monoize.sml	Tue Oct 21 11:13:03 2008 -0400
+++ b/src/monoize.sml	Tue Oct 21 11:19:17 2008 -0400
@@ -573,6 +573,13 @@
                                  (L'.TFfi ("Basis", "bool"), loc),
                                  (L'.EBinop ("==", (L'.ERel 1, loc), (L'.ERel 0, loc)), loc)), loc)), loc),
              fm)
+          | L.EFfi ("Basis", "eq_float") =>
+            ((L'.EAbs ("x", (L'.TFfi ("Basis", "float"), loc),
+                       (L'.TFun ((L'.TFfi ("Basis", "float"), loc), (L'.TFfi ("Basis", "bool"), loc)), loc),
+                       (L'.EAbs ("y", (L'.TFfi ("Basis", "float"), loc),
+                                 (L'.TFfi ("Basis", "bool"), loc),
+                                 (L'.EBinop ("==", (L'.ERel 1, loc), (L'.ERel 0, loc)), loc)), loc)), loc),
+             fm)
           | L.EFfi ("Basis", "eq_bool") =>
             ((L'.EAbs ("x", (L'.TFfi ("Basis", "bool"), loc),
                        (L'.TFun ((L'.TFfi ("Basis", "bool"), loc), (L'.TFfi ("Basis", "bool"), loc)), loc),
@@ -728,6 +735,32 @@
                        intBin "<",
                        intBin "<=")
             end
+          | L.EFfi ("Basis", "ord_float") =>
+            let
+                fun floatBin s =
+                    (L'.EAbs ("x", (L'.TFfi ("Basis", "float"), loc),
+                              (L'.TFun ((L'.TFfi ("Basis", "float"), loc), (L'.TFfi ("Basis", "bool"), loc)), loc),
+                              (L'.EAbs ("y", (L'.TFfi ("Basis", "float"), loc),
+                                        (L'.TFfi ("Basis", "bool"), loc),
+                                        (L'.EBinop (s, (L'.ERel 1, loc), (L'.ERel 0, loc)), loc)), loc)), loc)
+            in
+                ordEx ((L'.TFfi ("Basis", "float"), loc),
+                       floatBin "<",
+                       floatBin "<=")
+            end
+          | L.EFfi ("Basis", "ord_bool") =>
+            let
+                fun boolBin s =
+                    (L'.EAbs ("x", (L'.TFfi ("Basis", "bool"), loc),
+                              (L'.TFun ((L'.TFfi ("Basis", "bool"), loc), (L'.TFfi ("Basis", "bool"), loc)), loc),
+                              (L'.EAbs ("y", (L'.TFfi ("Basis", "bool"), loc),
+                                        (L'.TFfi ("Basis", "bool"), loc),
+                                        (L'.EBinop (s, (L'.ERel 1, loc), (L'.ERel 0, loc)), loc)), loc)), loc)
+            in
+                ordEx ((L'.TFfi ("Basis", "bool"), loc),
+                       boolBin "<",
+                       boolBin "<=")
+            end
                        
           | L.ECApp ((L.EFfi ("Basis", "show"), _), t) =>
             let
--- a/tests/ord.ur	Tue Oct 21 11:13:03 2008 -0400
+++ b/tests/ord.ur	Tue Oct 21 11:19:17 2008 -0400
@@ -1,3 +1,5 @@
 fun main () : transaction page = return <xml><body>
-  {[ 1 < 1 ]}, {[ 1 < 2 ]}, {[ 1 <= 1 ]}, {[ 2 <= 1 ]}, {[ 1 > 1 ]}, {[ 2 > 1 ]}, {[ 0 >= 1 ]}, {[ 2 >= 1 ]}
+  {[ 1 < 1 ]}, {[ 1 < 2 ]}, {[ 1 <= 1 ]}, {[ 2 <= 1 ]}, {[ 1 > 1 ]}, {[ 2 > 1 ]}, {[ 0 >= 1 ]}, {[ 2 >= 1 ]}<br/>
+  {[ 1.0 < 1.0 ]}, {[ 1.0 < 2.0 ]}, {[ 1.0 <= 1.0 ]}, {[ 2.0 <= 1.0 ]}, {[ 1.0 > 1.0 ]}, {[ 2.0 > 1.0 ]}, {[ 0.0 >= 1.0 ]}, {[ 2.0 >= 1.0 ]}<br/>
+  {[ True < False ]}, {[ False < True ]}, {[ False <= True ]}, {[ False > True ]}
 </body></xml>