diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ur/list.ur | 11 | ||||
-rw-r--r-- | lib/ur/list.urs | 3 |
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur index 0aae9010..89dc8bbd 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -150,3 +150,14 @@ fun search [a] [b] f = search' end +fun foldlM [m] (_ : monad m) [a] [b] f = + let + fun foldlM' acc ls = + case ls of + [] => return acc + | x :: ls => + acc <- f x acc; + foldlM' acc ls + in + foldlM' + end diff --git a/lib/ur/list.urs b/lib/ur/list.urs index 1b80a9d3..89e7eecb 100644 --- a/lib/ur/list.urs +++ b/lib/ur/list.urs @@ -24,6 +24,9 @@ val filter : a ::: Type -> (a -> bool) -> t a -> t a 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 foldlMap : a ::: Type -> b ::: Type -> c ::: Type -> (a -> b -> c * b) -> b -> t a -> t c * b |