Mercurial > urweb
comparison src/mono_util.sml @ 126:76a4d69719d8
Tagging (non-mutual) 'val rec'
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 17 Jul 2008 10:38:03 -0400 |
parents | 6230bdd122e7 |
children | f0d3402184d1 |
comparison
equal
deleted
inserted
replaced
125:fd98dd10dce7 | 126:76a4d69719d8 |
---|---|
256 fun mfd ctx d acc = | 256 fun mfd ctx d acc = |
257 S.bindP (mfd' ctx d acc, fd ctx) | 257 S.bindP (mfd' ctx d acc, fd ctx) |
258 | 258 |
259 and mfd' ctx (dAll as (d, loc)) = | 259 and mfd' ctx (dAll as (d, loc)) = |
260 case d of | 260 case d of |
261 DVal (x, n, t, e, s) => | 261 DVal vi => |
262 S.bind2 (mft t, | 262 S.map2 (mfvi ctx vi, |
263 fn t' => | 263 fn vi' => |
264 S.map2 (mfe ctx e, | 264 (DVal vi', loc)) |
265 fn e' => | 265 | DValRec vis => |
266 (DVal (x, n, t', e', s), loc))) | 266 S.map2 (ListUtil.mapfold (mfvi ctx) vis, |
267 fn vis' => | |
268 (DValRec vis', loc)) | |
267 | DExport (s, n, ts) => | 269 | DExport (s, n, ts) => |
268 S.map2 (ListUtil.mapfold mft ts, | 270 S.map2 (ListUtil.mapfold mft ts, |
269 fn ts' => | 271 fn ts' => |
270 (DExport (s, n, ts'), loc)) | 272 (DExport (s, n, ts'), loc)) |
273 | |
274 and mfvi ctx (x, n, t, e, s) = | |
275 S.bind2 (mft t, | |
276 fn t' => | |
277 S.map2 (mfe ctx e, | |
278 fn e' => | |
279 (x, n, t', e', s))) | |
271 in | 280 in |
272 mfd | 281 mfd |
273 end | 282 end |
274 | 283 |
275 fun mapfold {typ = fc, exp = fe, decl = fd} = | 284 fun mapfold {typ = fc, exp = fe, decl = fd} = |
303 fn d' => | 312 fn d' => |
304 let | 313 let |
305 val ctx' = | 314 val ctx' = |
306 case #1 d' of | 315 case #1 d' of |
307 DVal (x, n, t, e, s) => bind (ctx, NamedE (x, n, t, SOME e, s)) | 316 DVal (x, n, t, e, s) => bind (ctx, NamedE (x, n, t, SOME e, s)) |
317 | DValRec vis => foldl (fn ((x, n, t, e, s), ctx) => | |
318 bind (ctx, NamedE (x, n, t, SOME e, s))) ctx vis | |
308 | DExport _ => ctx | 319 | DExport _ => ctx |
309 in | 320 in |
310 S.map2 (mff ctx' ds', | 321 S.map2 (mff ctx' ds', |
311 fn ds' => | 322 fn ds' => |
312 d' :: ds') | 323 d' :: ds') |