diff src/monoize.sml @ 905:7a4b026e45dd

Library improvements; proper list [un]urlification; remove server-side ServerCalls; eta reduction in type inference
author Adam Chlipala <adamc@hcoop.net>
date Sun, 09 Aug 2009 16:13:27 -0400
parents 63114a2e5075
children 5fe49effbc83
line wrap: on
line diff
--- a/src/monoize.sml	Thu Aug 06 15:23:04 2009 -0400
+++ b/src/monoize.sml	Sun Aug 09 16:13:27 2009 -0400
@@ -93,7 +93,12 @@
                     L.TFun (c1, c2) => (L'.TFun (mt env dtmap c1, mt env dtmap c2), loc)
                   | L.TCFun _ => poly ()
                   | L.TRecord (L.CRecord ((L.KType, _), xcs), _) =>
-                    (L'.TRecord (map (fn (x, t) => (monoName env x, mt env dtmap t)) xcs), loc)
+                    let
+                        val xcs = map (fn (x, t) => (monoName env x, mt env dtmap t)) xcs
+                        val xcs = ListMergeSort.sort (fn ((x, _), (y, _)) => String.compare (x, y) = GREATER) xcs
+                    in
+                        (L'.TRecord xcs, loc)
+                    end
                   | L.TRecord _ => poly ()
 
                   | L.CApp ((L.CFfi ("Basis", "option"), _), t) =>
@@ -3076,6 +3081,8 @@
                                               e,
                                               monoType env t), fm)
                                         end) fm xes
+
+                val xes = ListMergeSort.sort (fn ((x, _, _), (y, _, _)) => String.compare (x, y) = GREATER) xes
             in
                 ((L'.ERecord xes, loc), fm)
             end
@@ -3154,6 +3161,12 @@
 
                 val (ek, fm) = monoExp (env, st, fm) ek
 
+                val unRpced = foldl (fn (e1, e2) => (L'.EApp (e2, e1), loc)) (L'.ENamed n, loc) es
+                val unRpced = (L'.EApp (unRpced, (L'.ERecord [], loc)), loc)
+                val unRpced = (L'.EApp (ek, unRpced), loc)
+                val unRpced = (L'.EApp (unRpced, (L'.ERecord [], loc)), loc)
+                val unit = (L'.TRecord [], loc)
+
                 val ekf = (L'.EAbs ("f",
                                     (L'.TFun (t,
                                               (L'.TFun ((L'.TRecord [], loc),
@@ -3171,9 +3184,9 @@
                               L'.ReadCookieWrite
                           else
                               L'.ReadOnly
-                val e = (L'.EServerCall (call, ek, t, eff), loc)
+
+                val e = (L'.EServerCall (call, ek, t, eff, unRpced), loc)
                 val e = liftExpInExp 0 e
-                val unit = (L'.TRecord [], loc)
                 val e = (L'.EAbs ("_", unit, unit, e), loc)
             in
                 (e, fm)