summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2017-02-01 09:24:17 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2017-02-01 09:24:17 -0500
commit59454c9766685b381603aaf116bb43a9515dbdba (patch)
tree47b836f3e04babac7337e53c80ec972a3f0ea5c0
parent41cd154483d45c5d2fb0abf392b9bdc63d42b94e (diff)
Option.app
-rw-r--r--lib/ur/option.ur5
-rw-r--r--lib/ur/option.urs1
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/ur/option.ur b/lib/ur/option.ur
index 05c50d1f..baa08466 100644
--- a/lib/ur/option.ur
+++ b/lib/ur/option.ur
@@ -40,6 +40,11 @@ fun mp [a] [b] f x =
None => None
| Some y => Some (f y)
+fun app [m] [a] (_ : monad m) (f : a -> m {}) x =
+ case x of
+ None => return ()
+ | Some y => f y
+
fun bind [a] [b] f x =
case x of
None => None
diff --git a/lib/ur/option.urs b/lib/ur/option.urs
index 126999a3..c30c40e7 100644
--- a/lib/ur/option.urs
+++ b/lib/ur/option.urs
@@ -9,6 +9,7 @@ val isNone : a ::: Type -> t a -> bool
val isSome : a ::: Type -> t a -> bool
val mp : a ::: Type -> b ::: Type -> (a -> b) -> t a -> t b
+val app : m ::: (Type -> Type) -> a ::: Type -> monad m -> (a -> m {}) -> t a -> m {}
val bind : a ::: Type -> b ::: Type -> (a -> option b) -> t a -> t b
val get : a ::: Type -> a -> option a -> a