diff src/elab_util.sml @ 191:aa54250f58ac

Parametrized datatypes through explify
author Adam Chlipala <adamc@hcoop.net>
date Fri, 08 Aug 2008 10:28:32 -0400
parents 8e9f97508f0d
children ab86aa858e6c
line wrap: on
line diff
--- a/src/elab_util.sml	Thu Aug 07 13:09:26 2008 -0400
+++ b/src/elab_util.sml	Fri Aug 08 10:28:32 2008 -0400
@@ -396,7 +396,7 @@
                         S.map2 (con ctx c,
                              fn c' =>
                                 (SgiCon (x, n, k', c'), loc)))
-              | SgiDatatype (x, n, xncs) =>
+              | SgiDatatype (x, n, xs, xncs) =>
                 S.map2 (ListUtil.mapfold (fn (x, n, c) =>
                                              case c of
                                                  NONE => S.return2 (x, n, c)
@@ -404,8 +404,8 @@
                                                  S.map2 (con ctx c,
                                                       fn c' => (x, n, SOME c'))) xncs,
                         fn xncs' =>
-                           (SgiDatatype (x, n, xncs'), loc))
-              | SgiDatatypeImp (x, n, m1, ms, s, xncs) =>
+                           (SgiDatatype (x, n, xs, xncs'), loc))
+              | SgiDatatypeImp (x, n, m1, ms, s, xs, xncs) =>
                 S.map2 (ListUtil.mapfold (fn (x, n, c) =>
                                              case c of
                                                  NONE => S.return2 (x, n, c)
@@ -413,7 +413,7 @@
                                                  S.map2 (con ctx c,
                                                       fn c' => (x, n, SOME c'))) xncs,
                         fn xncs' =>
-                           (SgiDatatypeImp (x, n, m1, ms, s, xncs'), loc))
+                           (SgiDatatypeImp (x, n, m1, ms, s, xs, xncs'), loc))
               | SgiVal (x, n, c) =>
                 S.map2 (con ctx c,
                      fn c' =>
@@ -445,9 +445,9 @@
                                                    bind (ctx, NamedC (x, k))
                                                  | SgiCon (x, _, k, _) =>
                                                    bind (ctx, NamedC (x, k))
-                                                 | SgiDatatype (x, n, xncs) =>
+                                                 | SgiDatatype (x, n, _, xncs) =>
                                                    bind (ctx, NamedC (x, (KType, loc)))
-                                                 | SgiDatatypeImp (x, _, _, _, _, _) =>
+                                                 | SgiDatatypeImp (x, _, _, _, _, _, _) =>
                                                    bind (ctx, NamedC (x, (KType, loc)))
                                                  | SgiVal _ => ctx
                                                  | SgiStr (x, _, sgn) =>
@@ -553,7 +553,7 @@
                                               (case #1 d of
                                                    DCon (x, _, k, _) =>
                                                    bind (ctx, NamedC (x, k))
-                                                 | DDatatype (x, n, xncs) =>
+                                                 | DDatatype (x, n, xs, xncs) =>
                                                    let
                                                        val ctx = bind (ctx, NamedC (x, (KType, loc)))
                                                    in
@@ -563,12 +563,21 @@
                                                                          case co of
                                                                              NONE => CNamed n
                                                                            | SOME t => TFun (t, (CNamed n, loc))
+
+                                                                     val k = (KType, loc)
+                                                                     val t = (t, loc)
+                                                                     val t = foldr (fn (x, t) =>
+                                                                                       (TCFun (Explicit,
+                                                                                               x,
+                                                                                               k,
+                                                                                               t), loc))
+                                                                             t xs
                                                                  in
-                                                                     bind (ctx, NamedE (x, (t, loc)))
+                                                                     bind (ctx, NamedE (x, t))
                                                                  end)
                                                        ctx xncs
                                                    end
-                                                 | DDatatypeImp (x, n, m, ms, x', _) =>
+                                                 | DDatatypeImp (x, n, m, ms, x', _, _) =>
                                                    bind (ctx, NamedC (x, (KType, loc)))
                                                  | DVal (x, _, c, _) =>
                                                    bind (ctx, NamedE (x, c))
@@ -616,7 +625,7 @@
                             S.map2 (mfc ctx c,
                                     fn c' =>
                                        (DCon (x, n, k', c'), loc)))
-              | DDatatype (x, n, xncs) =>
+              | DDatatype (x, n, xs, xncs) =>
                 S.map2 (ListUtil.mapfold (fn (x, n, c) =>
                                              case c of
                                                  NONE => S.return2 (x, n, c)
@@ -624,8 +633,8 @@
                                                  S.map2 (mfc ctx c,
                                                       fn c' => (x, n, SOME c'))) xncs,
                         fn xncs' =>
-                           (DDatatype (x, n, xncs'), loc))
-              | DDatatypeImp (x, n, m1, ms, s, xncs) =>
+                           (DDatatype (x, n, xs, xncs'), loc))
+              | DDatatypeImp (x, n, m1, ms, s, xs, xncs) =>
                 S.map2 (ListUtil.mapfold (fn (x, n, c) =>
                                              case c of
                                                  NONE => S.return2 (x, n, c)
@@ -633,7 +642,7 @@
                                                  S.map2 (mfc ctx c,
                                                       fn c' => (x, n, SOME c'))) xncs,
                         fn xncs' =>
-                           (DDatatypeImp (x, n, m1, ms, s, xncs'), loc))
+                           (DDatatypeImp (x, n, m1, ms, s, xs, xncs'), loc))
               | DVal vi =>
                 S.map2 (mfvi ctx vi,
                      fn vi' =>