diff src/monoize.sml @ 387:7abb28e9d51f

Binops; equality tested on int; lame 404 substitute
author Adam Chlipala <adamc@hcoop.net>
date Tue, 21 Oct 2008 09:50:19 -0400
parents 1195f6e4d208
children 2e93d18daf44
line wrap: on
line diff
--- a/src/monoize.sml	Sun Oct 19 16:49:09 2008 -0400
+++ b/src/monoize.sml	Tue Oct 21 09:50:19 2008 -0400
@@ -94,6 +94,12 @@
                   | 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 @@
             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