From 8bfef85c27fc16605ae5bf0e43975904900679c5 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 19 Oct 2010 11:51:53 -0400 Subject: Monad.appR --- 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 487aef26..0eb1a251 100644 --- a/lib/ur/monad.ur +++ b/lib/ur/monad.ur @@ -93,6 +93,16 @@ fun foldMapR [K] [m] (_ : monad m) [tf :: K -> Type] [tf' :: K -> Type] [tr :: { (fn _ => return ({}, i)) fl +fun appR [K] [m] (_ : monad m) [tf :: K -> Type] + (f : nm :: Name -> t :: K -> tf t -> m unit) + [r ::: {K}] (fl : folder r) = + @Top.fold [fn r :: {K} => $(map tf r) -> m unit] + (fn [nm :: Name] [t :: K] [rest :: {K}] [[nm] ~ rest] acc r => + acc (r -- nm); + f [nm] [t] r.nm) + (fn _ => return ()) + fl + fun appR2 [K] [m] (_ : monad m) [tf1 :: K -> Type] [tf2 :: K -> Type] (f : nm :: Name -> t :: K -> tf1 t -> tf2 t -> m unit) [r ::: {K}] (fl : folder r) = diff --git a/lib/ur/monad.urs b/lib/ur/monad.urs index be3b59ab..0bfef87a 100644 --- a/lib/ur/monad.urs +++ b/lib/ur/monad.urs @@ -61,6 +61,11 @@ val foldMapR : K --> m ::: (Type -> Type) -> monad m -> tr [] -> r ::: {K} -> folder r -> $(map tf r) -> m ($(map tf' r) * tr r) +val appR : K --> m ::: (Type -> Type) -> monad m + -> tf :: (K -> Type) + -> (nm :: Name -> t :: K -> tf t -> m unit) + -> r ::: {K} -> folder r -> $(map tf r) -> m unit + val appR2 : K --> m ::: (Type -> Type) -> monad m -> tf1 :: (K -> Type) -> tf2 :: (K -> Type) -> (nm :: Name -> t :: K -> tf1 t -> tf2 t -> m unit) -- cgit v1.2.3