diff options
author | Benjamin Barenblat <bbaren@mit.edu> | 2018-06-17 09:12:52 -0400 |
---|---|---|
committer | Benjamin Barenblat <bbaren@mit.edu> | 2018-06-17 09:12:52 -0400 |
commit | 095c2640aa2070ed4e2765875238d5e6e6673856 (patch) | |
tree | 9306beb3fef29a99d9436dc00e2d8c57fb3e0c7b /lib/ur/list.ur | |
parent | 8c58ba2e1db6e97ca1f18fd9ca52ffead53e4a4f (diff) | |
parent | 34eb9eba9a724433f9c37c39cf43e9e10cf55220 (diff) |
Merge branch 'upstream' into dfsg_clean20180616+dfsg
Diffstat (limited to 'lib/ur/list.ur')
-rw-r--r-- | lib/ur/list.ur | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/ur/list.ur b/lib/ur/list.ur index cc533676..95d6fbc8 100644 --- a/lib/ur/list.ur +++ b/lib/ur/list.ur @@ -204,6 +204,21 @@ fun exists [a] f = ex end +fun existsM [m] (_ : monad m) [a] f = + let + fun ex ls = + case ls of + [] => return False + | x :: ls => + b <- f x; + if b then + return True + else + ex ls + in + ex + end + fun foldlMap [a] [b] [c] f = let fun fold ls' st ls = @@ -240,6 +255,21 @@ fun find [a] f = find' end +fun findM [m] (_ : monad m) [a] f = + let + fun find' ls = + case ls of + [] => return None + | x :: ls => + b <- f x; + if b then + return (Some x) + else + find' ls + in + find' + end + fun search [a] [b] f = let fun search' ls = |