diff lib/ur/top.ur @ 630:6a6eb9882d57

Top.Fold.mp
author Adam Chlipala <adamc@hcoop.net>
date Tue, 24 Feb 2009 13:50:39 -0500
parents e68de2a5506b
children effa7d43aac3
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