diff options
author | Adam Chlipala <adam@chlipala.net> | 2019-01-24 12:10:09 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2019-01-24 12:10:09 -0500 |
commit | 24fc1cc302a087b2df3d2041b24011a8b65f499e (patch) | |
tree | e87762fb3acc2551a1dd8e47b93807c184712ec2 /lib/ur/option.ur | |
parent | 87d2eab53f8e9f81cc459429675123c9ff36f41e (diff) |
Option.mapM
Diffstat (limited to 'lib/ur/option.ur')
-rw-r--r-- | lib/ur/option.ur | 5 |
1 files changed, 5 insertions, 0 deletions
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 <xml>Option.unsafeGet: encountered None</xml> | 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) |