From c0bc51a495cc806fe18b7cd3bee63be6c0f7cf3e Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 21 Aug 2011 13:41:57 -0400 Subject: Fix another list unurlification segfault bug; List.foldlMi --- lib/ur/list.ur | 12 ++++++++++++ lib/ur/list.urs | 3 +++ 2 files changed, 15 insertions(+) (limited to 'lib') diff --git a/lib/ur/list.ur b/lib/ur/list.ur index 35440de2..6a754287 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -255,6 +255,18 @@ fun foldlM [m] (_ : monad m) [a] [b] f = foldlM' end +fun foldlMi [m] (_ : monad m) [a] [b] f = + let + fun foldlMi' i acc ls = + case ls of + [] => return acc + | x :: ls => + acc <- f i x acc; + foldlMi' (i + 1) acc ls + in + foldlMi' 0 + end + fun all [m] f = let fun all' ls = diff --git a/lib/ur/list.urs b/lib/ur/list.urs index 851d74bc..2a28d148 100644 --- a/lib/ur/list.urs +++ b/lib/ur/list.urs @@ -43,6 +43,9 @@ val exists : a ::: Type -> (a -> bool) -> t a -> bool val foldlM : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type -> (a -> b -> m b) -> b -> t a -> m b +val foldlMi : m ::: (Type -> Type) -> monad m -> a ::: Type -> b ::: Type + -> (int -> a -> b -> m b) -> b -> t a -> m b + val foldlMap : a ::: Type -> b ::: Type -> c ::: Type -> (a -> b -> c * b) -> b -> t a -> t c * b -- cgit v1.2.3