aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/expl_util.sml
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-05-16 15:22:05 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-05-16 15:22:05 -0400
commit6cb3888614811abc30c6a00a1644e256d1d1c780 (patch)
tree2880c44d43f0095ce5c1ac7531a4cdff3ce4b730 /src/expl_util.sml
parent0159bec5067ac88f3f222595ac6f5e2f94c1d41f (diff)
Mutual datatypes through Corify
Diffstat (limited to 'src/expl_util.sml')
-rw-r--r--src/expl_util.sml31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/expl_util.sml b/src/expl_util.sml
index 9e150b87..1932d52d 100644
--- a/src/expl_util.sml
+++ b/src/expl_util.sml
@@ -453,15 +453,17 @@ fun mapfoldB {kind, con, sgn_item, sgn, bind} =
S.map2 (con ctx c,
fn c' =>
(SgiCon (x, n, k', c'), loc)))
- | SgiDatatype (x, n, xs, xncs) =>
- S.map2 (ListUtil.mapfold (fn (x, n, c) =>
- case c of
- NONE => S.return2 (x, n, c)
- | SOME c =>
- S.map2 (con ctx c,
- fn c' => (x, n, SOME c'))) xncs,
- fn xncs' =>
- (SgiDatatype (x, n, xs, xncs'), loc))
+ | SgiDatatype dts =>
+ S.map2 (ListUtil.mapfold (fn (x, n, xs, xncs) =>
+ S.map2 (ListUtil.mapfold (fn (x, n, c) =>
+ case c of
+ NONE => S.return2 (x, n, c)
+ | SOME c =>
+ S.map2 (con ctx c,
+ fn c' => (x, n, SOME c'))) xncs,
+ fn xncs' => (x, n, xs, xncs'))) dts,
+ fn dts' =>
+ (SgiDatatype dts', loc))
| SgiDatatypeImp (x, n, m1, ms, s, xs, xncs) =>
S.map2 (ListUtil.mapfold (fn (x, n, c) =>
case c of
@@ -496,8 +498,15 @@ fun mapfoldB {kind, con, sgn_item, sgn, bind} =
bind (ctx, NamedC (x, k))
| SgiCon (x, _, k, _) =>
bind (ctx, NamedC (x, k))
- | SgiDatatype (x, n, _, xncs) =>
- bind (ctx, NamedC (x, (KType, loc)))
+ | SgiDatatype dts =>
+ foldl (fn ((x, _, ks, _), ctx) =>
+ let
+ val k' = (KType, loc)
+ val k = foldl (fn (_, k) => (KArrow (k', k), loc))
+ k' ks
+ in
+ bind (ctx, NamedC (x, k))
+ end) ctx dts
| SgiDatatypeImp (x, _, _, _, _, _, _) =>
bind (ctx, NamedC (x, (KType, loc)))
| SgiVal _ => ctx