From df475a9256347564d3adc1fafc53c4d93b4e73f7 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sat, 19 May 2012 11:32:12 -0400 Subject: Some standard library additions from Edward Z. Yang --- lib/ur/list.ur | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/ur/list.ur') diff --git a/lib/ur/list.ur b/lib/ur/list.ur index 2d5addc9..bce5335e 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -424,3 +424,16 @@ fun drop [a] (n : int) (xs : list a) : list a = fun splitAt [a] (n : int) (xs : list a) : list a * list a = (take n xs, drop n xs) + +fun mapXiM [m ::: Type -> Type] (_ : monad m) [a] [ctx ::: {Unit}] (f : int -> a -> m (xml ctx [] [])) : t a -> m (xml ctx [] []) = + let + fun mapXiM' i ls = + case ls of + [] => return + | x :: ls => + this <- f i x; + rest <- mapXiM' (i+1) ls; + return {this}{rest} + in + mapXiM' 0 + end -- cgit v1.2.3