changeset 1312:726f0caeea3f

Monad.appR
author Adam Chlipala <adam@chlipala.net>
date Tue, 19 Oct 2010 11:51:53 -0400
parents 5337adf33a4a
children 0bf73c3e4563
files lib/ur/monad.ur lib/ur/monad.urs
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/monad.ur	Tue Oct 19 10:13:24 2010 -0400
+++ b/lib/ur/monad.ur	Tue Oct 19 11:51:53 2010 -0400
@@ -93,6 +93,16 @@
      (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) =
--- a/lib/ur/monad.urs	Tue Oct 19 10:13:24 2010 -0400
+++ b/lib/ur/monad.urs	Tue Oct 19 11:51:53 2010 -0400
@@ -61,6 +61,11 @@
                -> 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)