changeset 796:6271f0e3c272

Fix a nasty binding bug in CoreUtil
author Adam Chlipala <adamc@hcoop.net>
date Thu, 14 May 2009 09:11:58 -0400
parents b87e71e45536
children 2c463eee89fa
files lib/ur/list.ur lib/ur/list.urs src/core_print.sml src/core_util.sml src/expl_print.sml src/unpoly.sml tests/pathmap.ur
diffstat 7 files changed, 42 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/list.ur	Thu May 14 08:15:36 2009 -0400
+++ b/lib/ur/list.ur	Thu May 14 09:11:58 2009 -0400
@@ -29,3 +29,13 @@
     in
         mp' []
     end
+
+fun mapX (a ::: Type) (ctx ::: {Unit}) f =
+    let
+        fun mapX' ls =
+            case ls of
+                [] => <xml/>
+              | x :: ls => <xml>{f x}{mapX' ls}</xml>
+    in
+        mapX'
+    end
--- a/lib/ur/list.urs	Thu May 14 08:15:36 2009 -0400
+++ b/lib/ur/list.urs	Thu May 14 09:11:58 2009 -0400
@@ -6,3 +6,4 @@
 
 val mp : a ::: Type -> b ::: Type -> (a -> b) -> t a -> t b
 
+val mapX : a ::: Type -> ctx ::: {Unit} -> (a -> xml ctx [] []) -> t a -> xml ctx [] []
--- a/src/core_print.sml	Thu May 14 08:15:36 2009 -0400
+++ b/src/core_print.sml	Thu May 14 09:11:58 2009 -0400
@@ -198,12 +198,18 @@
 fun p_patCon env pc =
     case pc of
         PConVar n => p_con_named env n
-      | PConFfi {mod = m, con, arg, ...} =>
+      | PConFfi {mod = m, con, arg, params, ...} =>
         if !debug then
             box [string "FFIC[",
                  case arg of
                      NONE => box []
-                   | SOME t => p_con env t,
+                   | SOME t =>
+                     let
+                         val k = (KType, ErrorMsg.dummySpan)
+                         val env' = foldl (fn (x, env) => E.pushCRel env x k) env params
+                     in
+                         p_con env' t
+                     end,
                  string "](",
                  string m,
                  string ".",
--- a/src/core_util.sml	Thu May 14 08:15:36 2009 -0400
+++ b/src/core_util.sml	Thu May 14 09:11:58 2009 -0400
@@ -772,7 +772,13 @@
               | PConFfi {mod = m, datatyp, params, con, arg, kind} =>
                 S.map2 ((case arg of
                              NONE => S.return2 NONE
-                           | SOME c => S.map2 (mfc ctx c, SOME)),
+                           | SOME c =>
+                             let
+                                 val k = (KType, ErrorMsg.dummySpan)
+                                 val ctx' = foldl (fn (x, ctx) => bind (ctx, RelC (x, k))) ctx params
+                             in
+                                 S.map2 (mfc ctx' c, SOME)
+                             end),
                         fn arg' =>
                            PConFfi {mod = m, datatyp = datatyp, params = params,
                                     con = con, arg = arg', kind = kind})
--- a/src/expl_print.sml	Thu May 14 08:15:36 2009 -0400
+++ b/src/expl_print.sml	Thu May 14 09:11:58 2009 -0400
@@ -219,9 +219,19 @@
       | PVar (s, _) => string s
       | PPrim p => Prim.p_t p
       | PCon (_, pc, _, NONE) => p_patCon env pc
-      | PCon (_, pc, _, SOME p) => parenIf par (box [p_patCon env pc,
-                                                     space,
-                                                     p_pat' true env p])
+      | PCon (_, pc, cs, SOME p) =>
+        if !debug then
+            parenIf par (box [p_patCon env pc,
+                              string "[",
+                              p_list (p_con env) cs,
+                              string "]",
+                              space,
+                              p_pat' true env p])
+        else
+            parenIf par (box [p_patCon env pc,
+                              space,
+                              p_pat' true env p])
+
       | PRecord xps =>
         box [string "{",
              p_list_sep (box [string ",", space]) (fn (x, p, _) =>
--- a/src/unpoly.sml	Thu May 14 08:15:36 2009 -0400
+++ b/src/unpoly.sml	Thu May 14 09:11:58 2009 -0400
@@ -138,14 +138,7 @@
                                                 in
                                                     trim (t, e, cargs)
                                                 end
-                                              | (_, _, []) =>
-                                                (*let
-                                                    val e = foldl (fn ((_, n, n_old, _, _, _), e) =>
-                                                                      unpolyNamed (n_old, ENamed n) e)
-                                                                  e vis
-                                                in*)
-                                                    SOME (t, e)
-                                                (*end*)
+                                              | (_, _, []) => SOME (t, e)
                                               | _ => NONE
                                     in
                                         (*Print.prefaces "specialize"
--- a/tests/pathmap.ur	Thu May 14 08:15:36 2009 -0400
+++ b/tests/pathmap.ur	Thu May 14 09:11:58 2009 -0400
@@ -4,5 +4,6 @@
 fun main () : transaction page = return <xml><body>
   {[x]}<br/>
   {[y]}<br/>
-  {[Aux.hello]}
+  {[Aux.hello]}<br/>
+  {List.mapX (fn n => <xml>{[n]}!</xml>) x}
 </body></xml>