Mercurial > urweb
comparison lib/ur/monad.ur @ 937:37dd42935dad
Summary row with aggregates
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 15 Sep 2009 10:18:56 -0400 |
parents | 321a2d6feb40 |
children | 8d3aa6c7cee0 |
comparison
equal
deleted
inserted
replaced
936:6966d98c80b5 | 937:37dd42935dad |
---|---|
57 (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] (v : tf t) | 57 (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] (v : tf t) |
58 (acc : $(map tr rest)) => | 58 (acc : $(map tr rest)) => |
59 v' <- f [nm] [t] v; | 59 v' <- f [nm] [t] v; |
60 return (acc ++ {nm = v'})) | 60 return (acc ++ {nm = v'})) |
61 {} | 61 {} |
62 | |
63 fun mapR2 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] [tr :: K -> Type] | |
64 (f : nm :: Name -> t :: K -> tf1 t -> tf2 t -> m (tr t)) = | |
65 @@foldR2 [m] _ [tf1] [tf2] [fn r => $(map tr r)] | |
66 (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] (v1 : tf1 t) (v2 : tf2 t) | |
67 (acc : $(map tr rest)) => | |
68 v' <- f [nm] [t] v1 v2; | |
69 return (acc ++ {nm = v'})) | |
70 {} |