comparison src/mono_util.sml @ 567:1901db85acb4

Start of JsComp
author Adam Chlipala <adamc@hcoop.net>
date Sat, 20 Dec 2008 14:19:21 -0500
parents a152905c3c3b
children 55fc747a67dc
comparison
equal deleted inserted replaced
566:a152905c3c3b 567:1901db85acb4
355 else 355 else
356 S.Continue (e, ())} k () of 356 S.Continue (e, ())} k () of
357 S.Return _ => true 357 S.Return _ => true
358 | S.Continue _ => false 358 | S.Continue _ => false
359 359
360 fun foldB {typ, exp, bind} ctx s e =
361 case mapfoldB {typ = fn t => fn s => S.Continue (t, typ (t, s)),
362 exp = fn ctx => fn e => fn s => S.Continue (e, exp (ctx, e, s)),
363 bind = bind} ctx e s of
364 S.Continue (_, s) => s
365 | S.Return _ => raise Fail "MonoUtil.Exp.foldB: Impossible"
366
360 end 367 end
361 368
362 structure Decl = struct 369 structure Decl = struct
363 370
364 datatype binder = datatype Exp.binder 371 datatype binder = datatype Exp.binder
430 case mapfold {typ = fn c => fn () => S.Continue (typ c, ()), 437 case mapfold {typ = fn c => fn () => S.Continue (typ c, ()),
431 exp = fn e => fn () => S.Continue (exp e, ()), 438 exp = fn e => fn () => S.Continue (exp e, ()),
432 decl = fn d => fn () => S.Continue (decl d, ())} e () of 439 decl = fn d => fn () => S.Continue (decl d, ())} e () of
433 S.Return () => raise Fail "MonoUtil.Decl.map: Impossible" 440 S.Return () => raise Fail "MonoUtil.Decl.map: Impossible"
434 | S.Continue (e, ()) => e 441 | S.Continue (e, ()) => e
442
443 fun foldMapB {typ, exp, decl, bind} ctx s d =
444 case mapfoldB {typ = fn c => fn s => S.Continue (typ (c, s)),
445 exp = fn ctx => fn e => fn s => S.Continue (exp (ctx, e, s)),
446 decl = fn ctx => fn d => fn s => S.Continue (decl (ctx, d, s)),
447 bind = bind} ctx d s of
448 S.Continue v => v
449 | S.Return _ => raise Fail "MonoUtil.Decl.foldMapB: Impossible"
435 450
436 end 451 end
437 452
438 structure File = struct 453 structure File = struct
439 454