# HG changeset patch # User Adam Chlipala # Date 1313948517 14400 # Node ID 553a5cc3a4b5a6a64e5afb935b163279a48ce877 # Parent 133c71008bef406c33126e04fcdbe9ea8105ff7b Fix another list unurlification segfault bug; List.foldlMi diff -r 133c71008bef -r 553a5cc3a4b5 lib/ur/list.ur --- a/lib/ur/list.ur Sun Aug 21 10:55:31 2011 -0400 +++ b/lib/ur/list.ur Sun Aug 21 13:41:57 2011 -0400 @@ -255,6 +255,18 @@ foldlM' end +fun foldlMi [m] (_ : monad m) [a] [b] f = + let + fun foldlMi' i acc ls = + case ls of + [] => return acc + | x :: ls => + acc <- f i x acc; + foldlMi' (i + 1) acc ls + in + foldlMi' 0 + end + fun all [m] f = let fun all' ls = diff -r 133c71008bef -r 553a5cc3a4b5 lib/ur/list.urs --- a/lib/ur/list.urs Sun Aug 21 10:55:31 2011 -0400 +++ b/lib/ur/list.urs Sun Aug 21 13:41:57 2011 -0400 @@ -43,6 +43,9 @@ val foldlM : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type -> (a -> b -> m b) -> b -> t a -> m b +val foldlMi : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type + -> (int -> a -> b -> m b) -> b -> t a -> m b + val foldlMap : a ::: Type -> b ::: Type -> c ::: Type -> (a -> b -> c * b) -> b -> t a -> t c * b diff -r 133c71008bef -r 553a5cc3a4b5 src/cjr_print.sml --- a/src/cjr_print.sml Sun Aug 21 10:55:31 2011 -0400 +++ b/src/cjr_print.sml Sun Aug 21 13:41:57 2011 -0400 @@ -861,7 +861,7 @@ space, string "+=", space, - string "3, ((*request)[0] == '/' ? ((*request)[0] = 0, (*request)++) : NULL)) : ((!strncmp(*request, \"Cons\", 4) && ((*request)[4] == 0 ", + string "3, ((*request)[0] == '/' ? ((*request)[0] = 0, ++*request) : NULL), NULL) : ((!strncmp(*request, \"Cons\", 4) && ((*request)[4] == 0 ", string "|| (*request)[4] == '/')) ? (*request", space, string "+=", diff -r 133c71008bef -r 553a5cc3a4b5 tests/rpcList2.ur --- a/tests/rpcList2.ur Sun Aug 21 10:55:31 2011 -0400 +++ b/tests/rpcList2.ur Sun Aug 21 13:41:57 2011 -0400 @@ -1,7 +1,13 @@ -fun rpcFunc l : transaction {} = return () +fun showList l = case l of + [] => "[]" + | h :: t => strcat (strcat (show h) " :: ") (showList t) + +fun rpcFunc l : transaction string = + case l of h :: _ => return (showList h) | [] => return "[]" fun main () : transaction page = return