comparison lib/ur/list.ur @ 818:066493f7f008

Change List.mapM' to avoid leaving functions around
author Adam Chlipala <adamc@hcoop.net>
date Thu, 21 May 2009 11:45:04 -0400
parents e92cfac1608f
children 395a5d450cc0
comparison
equal deleted inserted replaced
817:4585f744574a 818:066493f7f008
42 42
43 fun mapM (m ::: (Type -> Type)) (_ : monad m) (a ::: Type) (b ::: Type) f = 43 fun mapM (m ::: (Type -> Type)) (_ : monad m) (a ::: Type) (b ::: Type) f =
44 let 44 let
45 fun mapM' acc ls = 45 fun mapM' acc ls =
46 case ls of 46 case ls of
47 [] => acc 47 [] => return (rev acc)
48 | x :: ls => mapM' (x' <- f x; ls' <- acc; return (x' :: ls')) ls 48 | x :: ls => x' <- f x; mapM' (x' :: acc) ls
49 in 49 in
50 mapM' (return []) 50 mapM' []
51 end 51 end