Mercurial > urweb
diff src/reduce.sml @ 74:144d082b47ae
Reduce efold
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 26 Jun 2008 12:12:06 -0400 |
parents | 2e0f3b21fb85 |
children | 813e5a52063d |
line wrap: on
line diff
--- a/src/reduce.sml Thu Jun 26 11:32:29 2008 -0400 +++ b/src/reduce.sml Thu Jun 26 12:12:06 2008 -0400 @@ -41,10 +41,10 @@ con = fn (xn, rep) => fn c => case c of CRel xn' => - if xn = xn' then - #1 rep - else - c + (case Int.compare (xn', xn) of + EQUAL => #1 rep + | GREATER => CRel (xn' - 1) + | LESS => c) | _ => c, bind = fn ((xn, rep), U.Con.Rel _) => (xn+1, liftConInCon 0 rep) | (ctx, _) => ctx} @@ -69,10 +69,10 @@ exp = fn (xn, rep) => fn e => case e of ERel xn' => - if xn = xn' then - #1 rep - else - e + (case Int.compare (xn', xn) of + EQUAL => #1 rep + | GREATER=> ERel (xn' - 1) + | LESS => e) | _ => e, bind = fn ((xn, rep), U.Exp.RelE _) => (xn+1, liftExpInExp 0 rep) | (ctx, _) => ctx} @@ -96,10 +96,10 @@ con = fn (xn, rep) => fn c => case c of CRel xn' => - if xn = xn' then - #1 rep - else - c + (case Int.compare (xn', xn) of + EQUAL => #1 rep + | GREATER => CRel (xn' - 1) + | LESS => c) | _ => c, exp = fn _ => fn e => e, bind = fn ((xn, rep), U.Exp.RelC _) => (xn+1, liftConInCon 0 rep) @@ -146,6 +146,14 @@ (_, _, SOME e') => #1 e' | _ => e) + | ECApp ((EApp ((EApp ((ECApp ((EFold ks, _), ran), _), f), _), i), _), (CRecord (k, xcs), loc)) => + (case xcs of + [] => #1 i + | (n, v) :: rest => + #1 (reduceExp env (EApp ((ECApp ((ECApp ((ECApp (f, n), loc), v), loc), (CRecord (k, rest), loc)), loc), + (ECApp ((EApp ((EApp ((ECApp ((EFold ks, loc), ran), loc), f), loc), i), loc), + (CRecord (k, rest), loc)), loc)), loc))) + | EApp ((EAbs (_, _, _, e1), loc), e2) => #1 (reduceExp env (subExpInExp (0, e2) e1)) | ECApp ((ECAbs (_, _, e1), loc), c) =>