diff src/elab_util.sml @ 1732:4a03aa3251cb

Initial support for reusing elaboration results
author Adam Chlipala <adam@chlipala.net>
date Sun, 29 Apr 2012 13:17:31 -0400
parents 6c00d8af6239
children d28adceef22a
line wrap: on
line diff
--- a/src/elab_util.sml	Sat Apr 28 12:00:35 2012 -0400
+++ b/src/elab_util.sml	Sun Apr 29 13:17:31 2012 -0400
@@ -1180,6 +1180,17 @@
         S.Continue (s, ()) => s
       | S.Return _ => raise Fail "ElabUtil.Decl.mapB: Impossible"
 
+fun fold {kind, con, exp, sgn_item, sgn, str, decl} (st : 'a) d : 'a =
+    case mapfold {kind = fn k => fn st => S.Continue (k, kind (k, st)),
+                  con = fn c => fn st => S.Continue (c, con (c, st)),
+                  exp = fn e => fn st => S.Continue (e, exp (e, st)),
+                  sgn_item = fn sgi => fn st => S.Continue (sgi, sgn_item (sgi, st)),
+                  sgn = fn s => fn st => S.Continue (s, sgn (s, st)),
+                  str = fn str' => fn st => S.Continue (str', str (str', st)),
+                  decl = fn d => fn st => S.Continue (d, decl (d, st))} d st of
+        S.Continue (_, st) => st
+      | S.Return _ => raise Fail "ElabUtil.Decl.fold: Impossible"
+
 end
 
 structure File = struct