changeset 395:9f67aac13cf7

ord_string
author Adam Chlipala <adamc@hcoop.net>
date Tue, 21 Oct 2008 11:22:10 -0400
parents 9f6fe6f32961
children 040edfade639
files src/monoize.sml tests/ord.ur
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/monoize.sml	Tue Oct 21 11:19:17 2008 -0400
+++ b/src/monoize.sml	Tue Oct 21 11:22:10 2008 -0400
@@ -761,6 +761,23 @@
                        boolBin "<",
                        boolBin "<=")
             end
+          | L.EFfi ("Basis", "ord_string") =>
+            let
+                fun boolBin s =
+                    (L'.EAbs ("x", (L'.TFfi ("Basis", "string"), loc),
+                              (L'.TFun ((L'.TFfi ("Basis", "string"), loc), (L'.TFfi ("Basis", "bool"), loc)), loc),
+                              (L'.EAbs ("y", (L'.TFfi ("Basis", "string"), loc),
+                                        (L'.TFfi ("Basis", "bool"), loc),
+                                        (L'.EBinop (s,
+                                                    (L'.EBinop ("strcmp",
+                                                                (L'.ERel 1, loc),
+                                                                (L'.ERel 0, loc)), loc),
+                                                    (L'.EPrim (Prim.Int (Int64.fromInt 0)), loc)), loc)), loc)), loc)
+            in
+                ordEx ((L'.TFfi ("Basis", "string"), loc),
+                       boolBin "<",
+                       boolBin "<=")
+            end
                        
           | L.ECApp ((L.EFfi ("Basis", "show"), _), t) =>
             let
--- a/tests/ord.ur	Tue Oct 21 11:19:17 2008 -0400
+++ b/tests/ord.ur	Tue Oct 21 11:22:10 2008 -0400
@@ -1,5 +1,6 @@
 fun main () : transaction page = return <xml><body>
   {[ 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 ]}
+  {[ True < False ]}, {[ False < True ]}, {[ False <= True ]}, {[ False > True ]}<br/>
+  {[ "A" < "B" ]}, {[ "C" < "B" ]}
 </body></xml>