summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-10-21 11:19:17 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-10-21 11:19:17 -0400
commiteaa8b82f581b0b2c59e4867b2f5455084b6b181b (patch)
tree922127dfce596e6b321b6c1d4b695460491325e6
parent8d110361aec2e04253f964b304d3c42e35bdb918 (diff)
ord_float and ord_bool
-rw-r--r--lib/basis.urs4
-rw-r--r--src/monoize.sml33
-rw-r--r--tests/ord.ur4
3 files changed, 40 insertions, 1 deletions
diff --git a/lib/basis.urs b/lib/basis.urs
index 5aba5526..027e81ac 100644
--- a/lib/basis.urs
+++ b/lib/basis.urs
@@ -15,6 +15,7 @@ class eq
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 le : t ::: Type -> ord t -> t -> t -> bool
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 *)
diff --git a/src/monoize.sml b/src/monoize.sml
index 4e92c02e..8ffe3f1b 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -573,6 +573,13 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
(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 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
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
diff --git a/tests/ord.ur b/tests/ord.ur
index c5dac100..52e1c305 100644
--- a/tests/ord.ur
+++ b/tests/ord.ur
@@ -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>