aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@csail.mit.edu>2017-01-25 15:55:14 -0500
committerGravatar Adam Chlipala <adamc@csail.mit.edu>2017-01-25 15:55:14 -0500
commit41cd154483d45c5d2fb0abf392b9bdc63d42b94e (patch)
treef1cb3fdcd83bc3b28ad2b76a21f5c1d1e350cbca /lib
parentf7ab07f941b23ad64cdb6db04020fa7c595db8e4 (diff)
List.appi
Diffstat (limited to 'lib')
-rw-r--r--lib/ur/list.ur12
-rw-r--r--lib/ur/list.urs3
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur
index 50764e46..cc533676 100644
--- a/lib/ur/list.ur
+++ b/lib/ur/list.ur
@@ -311,6 +311,18 @@ fun app [m] (_ : monad m) [a] f =
app'
end
+fun appi [m] (_ : monad m) [a] f =
+ let
+ fun app' i ls =
+ case ls of
+ [] => return ()
+ | x :: ls =>
+ f i x;
+ app' (i + 1) ls
+ in
+ app' 0
+ end
+
fun mapQuery [tables ::: {{Type}}] [exps ::: {Type}] [t ::: Type]
[tables ~ exps] (q : sql_query [] [] tables exps)
(f : $(exps ++ map (fn fields :: {Type} => $fields) tables) -> t) =
diff --git a/lib/ur/list.urs b/lib/ur/list.urs
index 432d8c1a..fd56679d 100644
--- a/lib/ur/list.urs
+++ b/lib/ur/list.urs
@@ -65,6 +65,9 @@ val all : a ::: Type -> (a -> bool) -> t a -> bool
val app : m ::: (Type -> Type) -> monad m -> a ::: Type
-> (a -> m unit) -> t a -> m unit
+val appi : m ::: (Type -> Type) -> monad m -> a ::: Type
+ -> (int -> a -> m unit) -> t a -> m unit
+
val tabulateM : m ::: (Type -> Type) -> monad m -> a ::: Type
-> (int -> m a) -> int -> m (t a)