summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ur/list.ur10
-rw-r--r--lib/ur/list.urs2
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index 2679d877..35440de2 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -133,6 +133,16 @@ fun mapX [a] [ctx ::: {Unit}] f =
mapX'
end
+fun mapXi [a] [ctx ::: {Unit}] f =
+ let
+ fun mapX' i ls =
+ case ls of
+ [] => <xml/>
+ | x :: ls => <xml>{f i x}{mapX' (i + 1) ls}</xml>
+ in
+ mapX' 0
+ end
+
fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f =
let
fun mapM' acc ls =
diff --git a/lib/ur/list.urs b/lib/ur/list.urs
index 00bb5b48..851d74bc 100644
--- a/lib/ur/list.urs
+++ b/lib/ur/list.urs
@@ -26,6 +26,8 @@ val mapi : a ::: Type -> b ::: Type -> (int -> a -> b) -> t a -> t b
val mapX : a ::: Type -> ctx ::: {Unit} -> (a -> xml ctx [] []) -> t a -> xml ctx [] []
+val mapXi : a ::: Type -> ctx ::: {Unit} -> (int -> a -> xml ctx [] []) -> t a -> xml ctx [] []
+
val mapM : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type
-> (a -> m b) -> t a -> m (t b)