aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/ur/list.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2018-11-04 09:39:07 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2018-11-04 09:39:07 -0500
commit096fbda34b67cccd2026c44006bd9bc98d28c98c (patch)
treefccb9d193cab99a9823f39aa8e56250ec3811f61 /lib/ur/list.ur
parentdb6451caad44785887bb9c9a1781bd861a3a46ce (diff)
List.mapMi
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r--lib/ur/list.ur10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index d28d2868..0da9316e 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -153,6 +153,16 @@ fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f =
mapM' []
end
+fun mapMi [m ::: (Type -> Type)] (_ : monad m) [a] [b] f =
+ let
+ fun mapM' i acc ls =
+ case ls of
+ [] => return (rev acc)
+ | x :: ls => x' <- f i x; mapM' (i + 1) (x' :: acc) ls
+ in
+ mapM' 0 []
+ end
+
fun mapPartialM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f =
let
fun mapPartialM' acc ls =