Mercurial > urweb
changeset 840:e4a02e4fa35c
Fix unbound name problem in Jscomp injectors; more List stuff
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sat, 06 Jun 2009 15:29:34 -0400 |
parents | b2413e4dd109 |
children | 44c2c089ca15 |
files | lib/ur/list.ur lib/ur/list.urs src/jscomp.sml |
diffstat | 3 files changed, 25 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/ur/list.ur Sat Jun 06 14:09:30 2009 -0400 +++ b/lib/ur/list.ur Sat Jun 06 15:29:34 2009 -0400 @@ -150,3 +150,14 @@ search' end +fun foldlM [m] (_ : monad m) [a] [b] f = + let + fun foldlM' acc ls = + case ls of + [] => return acc + | x :: ls => + acc <- f x acc; + foldlM' acc ls + in + foldlM' + end
--- a/lib/ur/list.urs Sat Jun 06 14:09:30 2009 -0400 +++ b/lib/ur/list.urs Sat Jun 06 15:29:34 2009 -0400 @@ -24,6 +24,9 @@ val exists : a ::: Type -> (a -> bool) -> t a -> bool +val foldlM : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type + -> (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
--- a/src/jscomp.sml Sat Jun 06 14:09:30 2009 -0400 +++ b/src/jscomp.sml Sat Jun 06 15:29:34 2009 -0400 @@ -42,7 +42,7 @@ end) type state = { - decls : decl list, + decls : (string * int * (string * int * typ option) list) list, script : string list, included : IS.set, injectors : int IM.map, @@ -301,8 +301,8 @@ {disc = t, result = s}), loc) val body = (EAbs ("x", t, s, body), loc) - val st = {decls = (DValRec [("jsify", n', (TFun (t, s), loc), - body, "jsify")], loc) :: #decls st, + val st = {decls = ("jsify", n', (TFun (t, s), loc), + body, "jsify") :: #decls st, script = #script st, included = #included st, injectors = #injectors st, @@ -362,8 +362,8 @@ {disc = t, result = s}), loc) val body = (EAbs ("x", t, s, body), loc) - val st = {decls = (DValRec [("jsify", n', (TFun (t, s), loc), - body, "jsify")], loc) :: #decls st, + val st = {decls = ("jsify", n', (TFun (t, s), loc), + body, "jsify") :: #decls st, script = #script st, included = #included st, injectors = #injectors st, @@ -1337,8 +1337,13 @@ let (*val () = Print.preface ("doDecl", MonoPrint.p_decl MonoEnv.empty d)*) val (d, st) = decl (d, st) + + val ds = + case #decls st of + [] => [d] + | vis => [(DValRec vis, #2 d), d] in - (List.revAppend (#decls st, [d]), + (ds, {decls = [], script = #script st, included = #included st,