Mercurial > urweb
comparison src/reduce.sml @ 149:7420fa18d657
Record cut
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 24 Jul 2008 10:09:21 -0400 |
parents | 55d8cfa4d024 |
children | 8a70e2919e86 |
comparison
equal
deleted
inserted
replaced
148:15e8b9775539 | 149:7420fa18d657 |
---|---|
162 | EField ((ERecord xes, _), (CName x, _), _) => | 162 | EField ((ERecord xes, _), (CName x, _), _) => |
163 (case List.find (fn ((CName x', _), _, _) => x' = x | 163 (case List.find (fn ((CName x', _), _, _) => x' = x |
164 | _ => false) xes of | 164 | _ => false) xes of |
165 SOME (_, e, _) => #1 e | 165 SOME (_, e, _) => #1 e |
166 | NONE => e) | 166 | NONE => e) |
167 | ECut (r as (_, loc), _, {rest = (CRecord (k, xts), _), ...}) => | |
168 let | |
169 fun fields (remaining, passed) = | |
170 case remaining of | |
171 [] => [] | |
172 | (x, t) :: rest => | |
173 (x, | |
174 (EField (r, x, {field = t, | |
175 rest = (CRecord (k, List.revAppend (passed, rest)), loc)}), loc), | |
176 t) :: fields (rest, (x, t) :: passed) | |
177 in | |
178 #1 (reduceExp env (ERecord (fields (xts, [])), loc)) | |
179 end | |
167 | 180 |
168 | _ => e | 181 | _ => e |
169 | 182 |
170 and reduceExp env = U.Exp.mapB {kind = kind, con = con, exp = exp, bind = bind} env | 183 and reduceExp env = U.Exp.mapB {kind = kind, con = con, exp = exp, bind = bind} env |
171 | 184 |