aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/ur/monad.ur
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ur/monad.ur')
-rw-r--r--lib/ur/monad.ur9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/ur/monad.ur b/lib/ur/monad.ur
index 96c46311..efba7546 100644
--- a/lib/ur/monad.ur
+++ b/lib/ur/monad.ur
@@ -59,3 +59,12 @@ fun mapR [K] [m] (_ : monad m) [tf :: K -> Type] [tr :: K -> Type]
v' <- f [nm] [t] v;
return (acc ++ {nm = v'}))
{}
+
+fun mapR2 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] [tr :: K -> Type]
+ (f : nm :: Name -> t :: K -> tf1 t -> tf2 t -> m (tr t)) =
+ @@foldR2 [m] _ [tf1] [tf2] [fn r => $(map tr r)]
+ (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] (v1 : tf1 t) (v2 : tf2 t)
+ (acc : $(map tr rest)) =>
+ v' <- f [nm] [t] v1 v2;
+ return (acc ++ {nm = v'}))
+ {}