From c4631a8e9c0b2eb95e99f89357858f771578178a Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 21 Oct 2008 11:22:10 -0400 Subject: ord_string --- src/monoize.sml | 17 +++++++++++++++++ tests/ord.ur | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/monoize.sml b/src/monoize.sml index 8ffe3f1b..06156544 100644 --- a/src/monoize.sml +++ b/src/monoize.sml @@ -761,6 +761,23 @@ fun monoExp (env, st, fm) (all as (e, loc)) = 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 diff --git a/tests/ord.ur b/tests/ord.ur index 52e1c305..fe2dbe8d 100644 --- a/tests/ord.ur +++ b/tests/ord.ur @@ -1,5 +1,6 @@ fun main () : transaction page = return {[ 1 < 1 ]}, {[ 1 < 2 ]}, {[ 1 <= 1 ]}, {[ 2 <= 1 ]}, {[ 1 > 1 ]}, {[ 2 > 1 ]}, {[ 0 >= 1 ]}, {[ 2 >= 1 ]}
{[ 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 ]}
- {[ True < False ]}, {[ False < True ]}, {[ False <= True ]}, {[ False > True ]} + {[ True < False ]}, {[ False < True ]}, {[ False <= True ]}, {[ False > True ]}
+ {[ "A" < "B" ]}, {[ "C" < "B" ]}
-- cgit v1.2.3