summaryrefslogtreecommitdiff
path: root/src/unnest.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-28 12:07:05 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-28 12:07:05 -0400
commita735f6ea0ef8ec5895dfe7f895f89ee8c126de14 (patch)
tree702dbe43701e15a37f7811983aad78e069812704 /src/unnest.sml
parent43cd4231dea11d2cbb0151f144e4a98c618df396 (diff)
Destructing local let, to the point where demo compiles
Diffstat (limited to 'src/unnest.sml')
-rw-r--r--src/unnest.sml21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/unnest.sml b/src/unnest.sml
index 51b66aa4..3dfa741d 100644
--- a/src/unnest.sml
+++ b/src/unnest.sml
@@ -173,7 +173,7 @@ fun kind (_, k, st) = (k, st)
fun exp ((ks, ts), e as old, st : state) =
case e of
- ELet (eds, e) =>
+ ELet (eds, e, t) =>
let
(*val () = Print.prefaces "Letto" [("e", ElabPrint.p_exp E.empty (old, ErrorMsg.dummySpan))]*)
@@ -190,12 +190,23 @@ fun exp ((ks, ts), e as old, st : state) =
ListUtil.foldlMapConcat
(fn (ed, (ts, maxName, ds, subs, by)) =>
case #1 ed of
- EDVal (x, t, e) =>
+ EDVal (p, t, e) =>
let
val e = doSubst (e, subs, by)
+
+ fun doVars ((p, _), ts) =
+ case p of
+ PWild => ts
+ | PVar xt => xt :: ts
+ | PPrim _ => ts
+ | PCon (_, _, _, NONE) => ts
+ | PCon (_, _, _, SOME p) => doVars (p, ts)
+ | PRecord xpcs =>
+ foldl (fn ((_, p, _), ts) => doVars (p, ts))
+ ts xpcs
in
- ([(EDVal (x, t, e), #2 ed)],
- ((x, t) :: ts,
+ ([(EDVal (p, t, e), #2 ed)],
+ (doVars (p, ts),
maxName, ds,
((0, (ERel 0, #2 ed))
:: map (fn (n, e) => (n + 1, E.liftExpInExp 0 e)) subs),
@@ -341,7 +352,7 @@ fun exp ((ks, ts), e as old, st : state) =
(*Print.prefaces "Before" [("e", ElabPrint.p_exp ElabEnv.empty e),
("se", ElabPrint.p_exp ElabEnv.empty (doSubst' (e, subs))),
("e'", ElabPrint.p_exp ElabEnv.empty e')];*)
- (ELet (eds, e'),
+ (ELet (eds, e', t),
{maxName = maxName,
decls = ds})
(*(ELet (eds, doSubst (liftExpInExp (~(length subs - numRemaining)) (length subs) e) subs),*)