Mercurial > urweb
diff lib/ur/monad.ur @ 2272:b49d22a4eda8
Merge.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Sat, 31 Oct 2015 23:35:42 -0400 |
parents | cbd294994c69 |
children |
line wrap: on
line diff
--- a/lib/ur/monad.ur Wed Oct 21 09:18:36 2015 -0400 +++ b/lib/ur/monad.ur Sat Oct 31 23:35:42 2015 -0400 @@ -81,6 +81,15 @@ 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] =>