From f7ec390b4c8f0d6173c00b76dafb9e3beb96c75b Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 19 Oct 2010 15:26:12 -0400 Subject: Monad.appR3 --- lib/ur/monad.ur | 10 ++++++++++ lib/ur/monad.urs | 5 +++++ 2 files changed, 15 insertions(+) (limited to 'lib') diff --git a/lib/ur/monad.ur b/lib/ur/monad.ur index 0eb1a251..c64c8fb9 100644 --- a/lib/ur/monad.ur +++ b/lib/ur/monad.ur @@ -112,3 +112,13 @@ fun appR2 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] f [nm] [t] r1.nm r2.nm) (fn _ _ => return ()) fl + +fun appR3 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] [tf3 :: K -> Type] + (f : nm :: Name -> t :: K -> tf1 t -> tf2 t -> tf3 t -> m unit) + [r ::: {K}] (fl : folder r) = + @Top.fold [fn r :: {K} => $(map tf1 r) -> $(map tf2 r) -> $(map tf3 r) -> m unit] + (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] acc r1 r2 r3 => + acc (r1 -- nm) (r2 -- nm) (r3 -- nm); + f [nm] [t] r1.nm r2.nm r3.nm) + (fn _ _ _ => return ()) + fl diff --git a/lib/ur/monad.urs b/lib/ur/monad.urs index 0bfef87a..d07d5026 100644 --- a/lib/ur/monad.urs +++ b/lib/ur/monad.urs @@ -70,3 +70,8 @@ val appR2 : K --> m ::: (Type -> Type) -> monad m -> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> (nm :: Name -> t :: K -> tf1 t -> tf2 t -> m unit) -> r ::: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> m unit + +val appR3 : K --> m ::: (Type -> Type) -> monad m + -> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> tf3 :: (K -> Type) + -> (nm :: Name -> t :: K -> tf1 t -> tf2 t -> tf3 t -> m unit) + -> r ::: {K} -> folder r -> $(map tf1 r) -> $(map tf2 r) -> $(map tf3 r) -> m unit -- cgit v1.2.3