diff options
author | Adam Chlipala <adamc@hcoop.net> | 2008-07-29 13:16:21 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2008-07-29 13:16:21 -0400 |
commit | 4b511aa7ed5b36cb0a9adb898f881d6db0a89996 (patch) | |
tree | 116bd8e11b341df6999ea79432cb4386a48ca9fc /src/core_util.sml | |
parent | 4cbbb0bb751dd9e9dae9d6b621e563ee5c7ae1b4 (diff) |
Datatypes through corify
Diffstat (limited to 'src/core_util.sml')
-rw-r--r-- | src/core_util.sml | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core_util.sml b/src/core_util.sml index 1964ce9d..95c4f10f 100644 --- a/src/core_util.sml +++ b/src/core_util.sml @@ -390,6 +390,15 @@ fun mapfoldB {kind = fk, con = fc, exp = fe, decl = fd, bind} = S.map2 (mfc ctx c, fn c' => (DCon (x, n, k', c'), loc))) + | DDatatype (x, n, xncs) => + S.map2 (ListUtil.mapfold (fn (x, n, c) => + case c of + NONE => S.return2 (x, n, c) + | SOME c => + S.map2 (mfc ctx c, + fn c' => (x, n, SOME c'))) xncs, + fn xncs' => + (DDatatype (x, n, xncs'), loc)) | DVal vi => S.map2 (mfvi ctx vi, fn vi' => @@ -458,6 +467,21 @@ fun mapfoldB (all as {bind, ...}) = val ctx' = case #1 d' of DCon (x, n, k, c) => bind (ctx, NamedC (x, n, k, SOME c)) + | DDatatype (x, n, xncs) => + let + val ctx = bind (ctx, NamedC (x, n, (KType, #2 d'), NONE)) + val t = (CNamed n, #2 d') + in + foldl (fn ((x, n, to), ctx) => + let + val t = case to of + NONE => t + | SOME t' => (TFun (t', t), #2 d') + in + bind (ctx, NamedE (x, n, t, NONE, "")) + end) + ctx xncs + end | DVal (x, n, t, e, s) => bind (ctx, NamedE (x, n, t, SOME e, s)) | DValRec vis => foldl (fn ((x, n, t, e, s), ctx) => bind (ctx, NamedE (x, n, t, NONE, s))) |