From 24fc1cc302a087b2df3d2041b24011a8b65f499e Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Thu, 24 Jan 2019 12:10:09 -0500 Subject: Option.mapM --- lib/ur/option.ur | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/ur/option.ur') diff --git a/lib/ur/option.ur b/lib/ur/option.ur index baa08466..dd186161 100644 --- a/lib/ur/option.ur +++ b/lib/ur/option.ur @@ -59,3 +59,8 @@ fun unsafeGet [a] (o : option a) = case o of None => error Option.unsafeGet: encountered None | Some v => v + +fun mapM [m] (_ : monad m) [a] [b] (f : a -> m b) (x : t a) : m (t b) = + case x of + None => return None + | Some y => z <- f y; return (Some z) -- cgit v1.2.3