diff src/corify.sml @ 194:df5fd8f6913a

A multi-parameter datatype all the way through
author Adam Chlipala <adamc@hcoop.net>
date Sat, 09 Aug 2008 08:47:36 -0400
parents 8a70e2919e86
children ab86aa858e6c
line wrap: on
line diff
--- a/src/corify.sml	Fri Aug 08 17:55:51 2008 -0400
+++ b/src/corify.sml	Sat Aug 09 08:47:36 2008 -0400
@@ -534,11 +534,12 @@
 
              val dk = CoreUtil.classifyDatatype xncs
              val t = (L'.CNamed n, loc)
-             val t = ListUtil.foldli (fn (i, _, t) => (L'.CApp (t, (L'.CRel i, loc)), loc)) t xs
+             val nxs = length xs - 1
+             val t = ListUtil.foldli (fn (i, _, t) => (L'.CApp (t, (L'.CRel (nxs - i), loc)), loc)) t xs
              val k = (L'.KType, loc)
              val dcons = map (fn (x, n, to) =>
                                  let
-                                     val args = ListUtil.mapi (fn (i, _) => (L'.CRel i, loc)) xs
+                                     val args = ListUtil.mapi (fn (i, _) => (L'.CRel (nxs - i), loc)) xs
                                      val (e, t) =
                                          case to of
                                              NONE => ((L'.ECon (dk, L'.PConVar n, args, NONE), loc), t)
@@ -575,7 +576,8 @@
                                                         ((x, n, co), st)
                                                     end) st xncs
 
-             val c = ListUtil.foldli (fn (i, _, c) => (L'.CApp (c, (L'.CRel i, loc)), loc)) c xs
+             val nxs = length xs - 1
+             val c = ListUtil.foldli (fn (i, _, c) => (L'.CApp (c, (L'.CRel (nxs - i), loc)), loc)) c xs
              val k = (L'.KType, loc)
              val k' = foldl (fn (_, k') => (L'.KArrow (k, k'), loc)) k xs