Mercurial > urweb
comparison 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 |
comparison
equal
deleted
inserted
replaced
483:a0f47540d8ad | 484:685b41e85634 |
---|---|
707 con = fn c => fn s => S.Continue (c, con (c, s)), | 707 con = fn c => fn s => S.Continue (c, con (c, s)), |
708 exp = fn e => fn s => S.Continue (e, exp (e, s))} e s of | 708 exp = fn e => fn s => S.Continue (e, exp (e, s))} e s of |
709 S.Continue (_, s) => s | 709 S.Continue (_, s) => s |
710 | S.Return _ => raise Fail "CoreUtil.Exp.fold: Impossible" | 710 | S.Return _ => raise Fail "CoreUtil.Exp.fold: Impossible" |
711 | 711 |
712 fun foldB {kind, con, exp, bind} ctx s e = | |
713 case mapfoldB {kind = fn k => fn s => S.Continue (k, kind (k, s)), | |
714 con = fn ctx => fn c => fn s => S.Continue (c, con (ctx, c, s)), | |
715 exp = fn ctx => fn e => fn s => S.Continue (e, exp (ctx, e, s)), | |
716 bind = bind} ctx e s of | |
717 S.Continue (_, s) => s | |
718 | S.Return _ => raise Fail "CoreUtil.Exp.foldB: Impossible" | |
719 | |
712 fun exists {kind, con, exp} k = | 720 fun exists {kind, con, exp} k = |
713 case mapfold {kind = fn k => fn () => | 721 case mapfold {kind = fn k => fn () => |
714 if kind k then | 722 if kind k then |
715 S.Return () | 723 S.Return () |
716 else | 724 else |
858 con = fn c => fn s => S.Continue (con (c, s)), | 866 con = fn c => fn s => S.Continue (con (c, s)), |
859 exp = fn e => fn s => S.Continue (exp (e, s)), | 867 exp = fn e => fn s => S.Continue (exp (e, s)), |
860 decl = fn d => fn s => S.Continue (decl (d, s))} d s of | 868 decl = fn d => fn s => S.Continue (decl (d, s))} d s of |
861 S.Continue v => v | 869 S.Continue v => v |
862 | S.Return _ => raise Fail "CoreUtil.Decl.foldMap: Impossible" | 870 | S.Return _ => raise Fail "CoreUtil.Decl.foldMap: Impossible" |
871 | |
872 fun foldMapB {kind, con, exp, decl, bind} ctx s d = | |
873 case mapfoldB {kind = fn k => fn s => S.Continue (kind (k, s)), | |
874 con = fn ctx => fn c => fn s => S.Continue (con (ctx, c, s)), | |
875 exp = fn ctx => fn e => fn s => S.Continue (exp (ctx, e, s)), | |
876 decl = fn ctx => fn d => fn s => S.Continue (decl (ctx, d, s)), | |
877 bind = bind} ctx d s of | |
878 S.Continue v => v | |
879 | S.Return _ => raise Fail "CoreUtil.Decl.foldMapB: Impossible" | |
863 | 880 |
864 end | 881 end |
865 | 882 |
866 structure File = struct | 883 structure File = struct |
867 | 884 |