Mercurial > urweb
comparison src/core_util.sml @ 110:3739af9e727a
Starting with closure links
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 13 Jul 2008 11:43:57 -0400 |
parents | 813e5a52063d |
children | fd98dd10dce7 |
comparison
equal
deleted
inserted
replaced
109:813e5a52063d | 110:3739af9e727a |
---|---|
289 | 289 |
290 | EWrite e => | 290 | EWrite e => |
291 S.map2 (mfe ctx e, | 291 S.map2 (mfe ctx e, |
292 fn e' => | 292 fn e' => |
293 (EWrite e', loc)) | 293 (EWrite e', loc)) |
294 | |
295 | EClosure (n, es) => | |
296 S.map2 (ListUtil.mapfold (mfe ctx) es, | |
297 fn es' => | |
298 (EClosure (n, es'), loc)) | |
294 in | 299 in |
295 mfe | 300 mfe |
296 end | 301 end |
297 | 302 |
298 fun mapfold {kind = fk, con = fc, exp = fe} = | 303 fun mapfold {kind = fk, con = fc, exp = fe} = |
398 con = fn c => fn s => S.Continue (c, con (c, s)), | 403 con = fn c => fn s => S.Continue (c, con (c, s)), |
399 exp = fn e => fn s => S.Continue (e, exp (e, s)), | 404 exp = fn e => fn s => S.Continue (e, exp (e, s)), |
400 decl = fn d => fn s => S.Continue (d, decl (d, s))} d s of | 405 decl = fn d => fn s => S.Continue (d, decl (d, s))} d s of |
401 S.Continue (_, s) => s | 406 S.Continue (_, s) => s |
402 | S.Return _ => raise Fail "CoreUtil.Decl.fold: Impossible" | 407 | S.Return _ => raise Fail "CoreUtil.Decl.fold: Impossible" |
408 | |
409 fun foldMap {kind, con, exp, decl} s d = | |
410 case mapfold {kind = fn k => fn s => S.Continue (kind (k, s)), | |
411 con = fn c => fn s => S.Continue (con (c, s)), | |
412 exp = fn e => fn s => S.Continue (exp (e, s)), | |
413 decl = fn d => fn s => S.Continue (decl (d, s))} d s of | |
414 S.Continue v => v | |
415 | S.Return _ => raise Fail "CoreUtil.Decl.foldMap: Impossible" | |
403 | 416 |
404 end | 417 end |
405 | 418 |
406 structure File = struct | 419 structure File = struct |
407 | 420 |
454 exp = fn e => fn s => S.Continue (e, exp (e, s)), | 467 exp = fn e => fn s => S.Continue (e, exp (e, s)), |
455 decl = fn d => fn s => S.Continue (d, decl (d, s))} d s of | 468 decl = fn d => fn s => S.Continue (d, decl (d, s))} d s of |
456 S.Continue (_, s) => s | 469 S.Continue (_, s) => s |
457 | S.Return _ => raise Fail "CoreUtil.File.fold: Impossible" | 470 | S.Return _ => raise Fail "CoreUtil.File.fold: Impossible" |
458 | 471 |
459 end | 472 fun foldMap {kind, con, exp, decl} s d = |
460 | 473 case mapfold {kind = fn k => fn s => S.Continue (kind (k, s)), |
461 end | 474 con = fn c => fn s => S.Continue (con (c, s)), |
475 exp = fn e => fn s => S.Continue (exp (e, s)), | |
476 decl = fn d => fn s => S.Continue (decl (d, s))} d s of | |
477 S.Continue v => v | |
478 | S.Return _ => raise Fail "CoreUtil.File.foldMap: Impossible" | |
479 | |
480 end | |
481 | |
482 end |