summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2015-10-31 11:49:30 -0400
committerGravatar Adam Chlipala <adam@chlipala.net>2015-10-31 11:49:30 -0400
commitb22998fc7c7984e35e3465ea4f66579523e85e0d (patch)
treefacd7fbd53d55b53764476ec4c8b2b92be4fd3b6
parent9522a0b394273e23c3b0492f2630e600e596488e (diff)
Monad.mapR3
-rw-r--r--lib/ur/monad.ur9
-rw-r--r--lib/ur/monad.urs6
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/ur/monad.ur b/lib/ur/monad.ur
index ab7742fe..8bff0133 100644
--- a/lib/ur/monad.ur
+++ b/lib/ur/monad.ur
@@ -81,6 +81,15 @@ fun mapR2 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] [tr :: K -
return (acc ++ {nm = v'}))
{}
+fun mapR3 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] [tf3 :: K -> Type] [tr :: K -> Type]
+ (f : nm :: Name -> t :: K -> tf1 t -> tf2 t -> tf3 t -> m (tr t)) =
+ @@foldR3 [m] _ [tf1] [tf2] [tf3] [fn r => $(map tr r)]
+ (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] (v1 : tf1 t) (v2 : tf2 t) (v3 : tf3 t)
+ (acc : $(map tr rest)) =>
+ v' <- f [nm] [t] v1 v2 v3;
+ return (acc ++ {nm = v'}))
+ {}
+
fun foldMapR [K] [m] (_ : monad m) [tf :: K -> Type] [tf' :: K -> Type] [tr :: {K} -> Type]
(f : nm :: Name -> t :: K -> rest :: {K}
-> [[nm] ~ rest] =>
diff --git a/lib/ur/monad.urs b/lib/ur/monad.urs
index ce823f4a..8ca8d0a3 100644
--- a/lib/ur/monad.urs
+++ b/lib/ur/monad.urs
@@ -58,6 +58,12 @@ val mapR2 : K --> m ::: (Type -> Type) -> monad m
-> (nm :: Name -> t :: K -> tf1 t -> tf2 t -> m (tr t))
-> r ::: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> m ($(map tr r))
+val mapR3 : K --> m ::: (Type -> Type) -> monad m
+ -> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> tf3 :: (K -> Type)
+ -> tr :: (K -> Type)
+ -> (nm :: Name -> t :: K -> tf1 t -> tf2 t -> tf3 t -> m (tr t))
+ -> r ::: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> $(map tf3 r) -> m ($(map tr r))
+
val foldMapR : K --> m ::: (Type -> Type) -> monad m
-> tf :: (K -> Type)
-> tf' :: (K -> Type)