summaryrefslogtreecommitdiff
path: root/src/monoize.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-10-21 09:50:19 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-10-21 09:50:19 -0400
commitf750e27d0e16da032227dbc71ecb7c63f5b77bc7 (patch)
treec1cd77d3f82dedbd270450204612186c547a83e8 /src/monoize.sml
parent4f6178266ffe0bf5423878b46486b82c19a56810 (diff)
Binops; equality tested on int; lame 404 substitute
Diffstat (limited to 'src/monoize.sml')
-rw-r--r--src/monoize.sml39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/monoize.sml b/src/monoize.sml
index 720a9485..7428b7fa 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -94,6 +94,12 @@ fun monoType env =
| L.CApp ((L.CFfi ("Basis", "option"), _), t) =>
(L'.TOption (mt env dtmap t), loc)
+ | L.CApp ((L.CFfi ("Basis", "eq"), _), t) =>
+ let
+ val t = mt env dtmap t
+ in
+ (L'.TFun (t, (L'.TFun (t, (L'.TFfi ("Basis", "bool"), loc)), loc)), loc)
+ end
| L.CApp ((L.CFfi ("Basis", "show"), _), t) =>
(L'.TFun (mt env dtmap t, (L'.TFfi ("Basis", "string"), loc)), loc)
| L.CApp ((L.CFfi ("Basis", "read"), _), t) =>
@@ -492,6 +498,39 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
end
| L.ECon _ => poly ()
+ | L.ECApp ((L.EFfi ("Basis", "eq"), _), t) =>
+ let
+ val t = monoType env t
+ val b = (L'.TFfi ("Basis", "bool"), loc)
+ val dom = (L'.TFun (t, (L'.TFun (t, b), loc)), loc)
+ in
+ ((L'.EAbs ("f", dom, dom,
+ (L'.ERel 0, loc)), loc), fm)
+ end
+ | L.ECApp ((L.EFfi ("Basis", "ne"), _), t) =>
+ let
+ val t = monoType env t
+ val b = (L'.TFfi ("Basis", "bool"), loc)
+ val dom = (L'.TFun (t, (L'.TFun (t, b), loc)), loc)
+ in
+ ((L'.EAbs ("f", dom, dom,
+ (L'.EAbs ("x", t, (L'.TFun (t, b), loc),
+ (L'.EAbs ("y", t, b,
+ (L'.EUnop ("!", (L'.EApp ((L'.EApp ((L'.ERel 2, loc),
+ (L'.ERel 1, loc)), loc),
+ (L'.ERel 0, loc)), loc)), loc)),
+ loc)),
+ loc)),
+ loc), fm)
+ end
+ | L.EFfi ("Basis", "eq_int") =>
+ ((L'.EAbs ("x", (L'.TFfi ("Basis", "int"), loc),
+ (L'.TFun ((L'.TFfi ("Basis", "int"), loc), (L'.TFfi ("Basis", "bool"), loc)), loc),
+ (L'.EAbs ("y", (L'.TFfi ("Basis", "int"), loc),
+ (L'.TFfi ("Basis", "bool"), loc),
+ (L'.EBinop ("==", (L'.ERel 1, loc), (L'.ERel 0, loc)), loc)), loc)), loc),
+ fm)
+
| L.ECApp ((L.EFfi ("Basis", "show"), _), t) =>
let
val t = monoType env t