changeset 630:6a6eb9882d57

Top.Fold.mp
author Adam Chlipala <adamc@hcoop.net>
date Tue, 24 Feb 2009 13:50:39 -0500
parents e68de2a5506b
children effa7d43aac3
files lib/ur/top.ur lib/ur/top.urs
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/top.ur	Tue Feb 24 13:46:08 2009 -0500
+++ b/lib/ur/top.ur	Tue Feb 24 13:50:39 2009 -0500
@@ -29,6 +29,17 @@
                             [[nm] ~ r1'] [[nm = v] ++ r1' ~ r2] =>
                f [nm] [v] [r1' ++ r2] acc !)
            (fn [[] ~ r2] => f2 [tf] f i) !
+
+    fun mp K1 K2 (f ::: K1 -> K2) (r ::: {K1})
+        (fold : folder r)
+        (tf :: {K2} -> Type)
+        (f : nm :: Name -> v :: K2 -> r :: {K2} -> tf r
+             -> [[nm] ~ r] => tf ([nm = v] ++ r))
+        (i : tf []) =
+        fold [fn r => tf (map f r)]
+        (fn (nm :: Name) (v :: K1) (rest :: {K1}) (acc : tf (map f rest)) [[nm] ~ rest] =>
+            f [nm] [f v] [map f rest] acc !)
+        i
 end
 
 
--- a/lib/ur/top.urs	Tue Feb 24 13:46:08 2009 -0500
+++ b/lib/ur/top.urs	Tue Feb 24 13:50:39 2009 -0500
@@ -12,6 +12,8 @@
                -> [[nm] ~ r] => folder r -> folder ([nm = v] ++ r)
     val concat : K --> r1 ::: {K} -> r2 ::: {K}
                  -> [r1 ~ r2] => folder r1 -> folder r2 -> folder (r1 ++ r2)
+    val mp : K1 --> K2 --> f ::: (K1 -> K2) -> r ::: {K1}
+             -> folder r -> folder (map f r)
 end