# HG changeset patch # User Adam Chlipala # Date 1313418129 14400 # Node ID dde3bd82cb3d534c8a04efc26dcb6adf233c71f4 # Parent ade93cd5bc5904035077c1a5014917157e4a1352 List.mapXi diff -r ade93cd5bc59 -r dde3bd82cb3d lib/ur/list.ur --- a/lib/ur/list.ur Sun Aug 14 17:39:18 2011 -0400 +++ b/lib/ur/list.ur Mon Aug 15 10:22:09 2011 -0400 @@ -133,6 +133,16 @@ mapX' end +fun mapXi [a] [ctx ::: {Unit}] f = + let + fun mapX' i ls = + case ls of + [] => + | x :: ls => {f i x}{mapX' (i + 1) ls} + in + mapX' 0 + end + fun mapM [m ::: (Type -> Type)] (_ : monad m) [a] [b] f = let fun mapM' acc ls = diff -r ade93cd5bc59 -r dde3bd82cb3d lib/ur/list.urs --- a/lib/ur/list.urs Sun Aug 14 17:39:18 2011 -0400 +++ b/lib/ur/list.urs Mon Aug 15 10:22:09 2011 -0400 @@ -26,6 +26,8 @@ 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)