aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/ur
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ur')
-rw-r--r--lib/ur/list.ur10
-rw-r--r--lib/ur/list.urs3
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index ecec2bec..2ee60538 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -39,3 +39,13 @@ fun mapX (a ::: Type) (ctx ::: {Unit}) f =
in
mapX'
end
+
+fun mapM (m ::: (Type -> Type)) (_ : monad m) (a ::: Type) (b ::: Type) f =
+ let
+ fun mapM' acc ls =
+ case ls of
+ [] => acc
+ | x :: ls => mapM' (x' <- f x; ls' <- acc; return (x' :: ls')) ls
+ in
+ mapM' (return [])
+ end
diff --git a/lib/ur/list.urs b/lib/ur/list.urs
index e9e097d4..d27ad997 100644
--- a/lib/ur/list.urs
+++ b/lib/ur/list.urs
@@ -7,3 +7,6 @@ val rev : a ::: Type -> t a -> t a
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 [] []
+
+val mapM : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type
+ -> (a -> m b) -> list a -> m (list b)