diff 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
line wrap: on
line diff
--- a/src/mono_util.sml	Fri Dec 19 12:38:11 2008 -0500
+++ b/src/mono_util.sml	Sat Dec 20 14:19:21 2008 -0500
@@ -357,6 +357,13 @@
         S.Return _ => true
       | S.Continue _ => false
 
+fun foldB {typ, exp, bind} ctx s e =
+    case mapfoldB {typ = fn t => fn s => S.Continue (t, typ (t, s)),
+                   exp = fn ctx => fn e => fn s => S.Continue (e, exp (ctx, e, s)),
+                   bind = bind} ctx e s of
+        S.Continue (_, s) => s
+      | S.Return _ => raise Fail "MonoUtil.Exp.foldB: Impossible"
+
 end
 
 structure Decl = struct
@@ -433,6 +440,14 @@
         S.Return () => raise Fail "MonoUtil.Decl.map: Impossible"
       | S.Continue (e, ()) => e
 
+fun foldMapB {typ, exp, decl, bind} ctx s d =
+    case mapfoldB {typ = fn c => fn s => S.Continue (typ (c, s)),
+                   exp = fn ctx => fn e => fn s => S.Continue (exp (ctx, e, s)),
+                   decl = fn ctx => fn d => fn s => S.Continue (decl (ctx, d, s)),
+                   bind = bind} ctx d s of
+        S.Continue v => v
+      | S.Return _ => raise Fail "MonoUtil.Decl.foldMapB: Impossible"
+
 end
 
 structure File = struct