diff src/core_util.sml @ 484:685b41e85634

Defunctionalization gets CommentBlog working
author Adam Chlipala <adamc@hcoop.net>
date Sun, 09 Nov 2008 16:54:42 -0500
parents 9117a7bf229c
children 5521bb0b4014
line wrap: on
line diff
--- a/src/core_util.sml	Sun Nov 09 12:41:34 2008 -0500
+++ b/src/core_util.sml	Sun Nov 09 16:54:42 2008 -0500
@@ -709,6 +709,14 @@
         S.Continue (_, s) => s
       | S.Return _ => raise Fail "CoreUtil.Exp.fold: Impossible"
 
+fun foldB {kind, con, exp, bind} ctx s e =
+    case mapfoldB {kind = fn k => fn s => S.Continue (k, kind (k, s)),
+                  con = fn ctx => fn c => fn s => S.Continue (c, con (ctx, c, 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 "CoreUtil.Exp.foldB: Impossible"
+
 fun exists {kind, con, exp} k =
     case mapfold {kind = fn k => fn () =>
                                     if kind k then
@@ -861,6 +869,15 @@
         S.Continue v => v
       | S.Return _ => raise Fail "CoreUtil.Decl.foldMap: Impossible"
 
+fun foldMapB {kind, con, exp, decl, bind} ctx s d =
+    case mapfoldB {kind = fn k => fn s => S.Continue (kind (k, s)),
+                   con = fn ctx => fn c => fn s => S.Continue (con (ctx, 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 "CoreUtil.Decl.foldMapB: Impossible"
+
 end
 
 structure File = struct