aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/ur/monad.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-09-15 10:18:56 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-09-15 10:18:56 -0400
commit44eb43907a88455c0cf223a411860a27d59c78b6 (patch)
treeb81fba316b6a552d9b1cf527831175d0926da43f /lib/ur/monad.ur
parenta8fa8a4567570b1925ff11b17da729ac32cd191e (diff)
Summary row with aggregates
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'}))
+ {}