summaryrefslogtreecommitdiff
path: root/src/mono_reduce.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2008-09-11 10:14:59 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2008-09-11 10:14:59 -0400
commitb404fdb16497e263484383464234f3ddf1d62150 (patch)
treec8ffe0ed690301c79e9a40ece3de7727355e87b4 /src/mono_reduce.sml
parent7bc788c67ed9331773355ceeae4ace7923a6e914 (diff)
Unpolyed a polymorphic function of two arguments
Diffstat (limited to 'src/mono_reduce.sml')
-rw-r--r--src/mono_reduce.sml19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mono_reduce.sml b/src/mono_reduce.sml
index 11a52a4c..e538f54e 100644
--- a/src/mono_reduce.sml
+++ b/src/mono_reduce.sml
@@ -95,6 +95,21 @@ fun subExpInExp (n, e1) e2 =
fun typ c = c
+val swapExpVars =
+ U.Exp.mapB {typ = fn t => t,
+ exp = fn lower => fn e =>
+ case e of
+ ERel xn =>
+ if xn = lower then
+ ERel (lower + 1)
+ else if xn = lower + 1 then
+ ERel lower
+ else
+ e
+ | _ => e,
+ bind = fn (lower, U.Exp.RelE _) => lower+1
+ | (lower, _) => lower}
+
datatype result = Yes of E.env | No | Maybe
fun match (env, p : pat, e : exp) =
@@ -208,6 +223,10 @@ fun exp env e =
| EApp ((ELet (x, t, e, b), loc), e') =>
#1 (reduceExp env (ELet (x, t, e,
(EApp (b, liftExpInExp 0 e'), loc)), loc))
+
+ | ELet (x, t, e, (EAbs (x', t' as (TRecord [], _), ran, e'), loc)) =>
+ EAbs (x', t', ran, (ELet (x, t, liftExpInExp 0 e, swapExpVars 0 e'), loc))
+
| ELet (x, t, e', b) =>
if impure e' then
e