changeset 631:effa7d43aac3

Make folders abstract
author Adam Chlipala <adamc@hcoop.net>
date Tue, 24 Feb 2009 14:04:07 -0500
parents 6a6eb9882d57
children 6c4643880df5
files demo/sum.ur lib/ur/top.ur lib/ur/top.urs
diffstat 3 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/demo/sum.ur	Tue Feb 24 13:50:39 2009 -0500
+++ b/demo/sum.ur	Tue Feb 24 14:04:07 2009 -0500
@@ -5,6 +5,6 @@
 
 fun main () = return <xml><body>
   {[sum Folder.nil {}]}<br/>
-  {[sum (Folder.cons [#A] [()] (Folder.cons [#B] [()] Folder.nil)) {A = 0, B = 1}]}<br/>
-  {[sum (Folder.cons [#D] [()] (Folder.cons [#C] [()] (Folder.cons [#E] [()] Folder.nil))) {C = 2, D = 3, E = 4}]}
+  {[sum (Folder.cons [#A] [()] ! (Folder.cons [#B] [()] ! Folder.nil)) {A = 0, B = 1}]}<br/>
+  {[sum (Folder.cons [#D] [()] ! (Folder.cons [#C] [()] ! (Folder.cons [#E] [()] ! Folder.nil))) {C = 2, D = 3, E = 4}]}
 </body></xml>
--- a/lib/ur/top.ur	Tue Feb 24 13:50:39 2009 -0500
+++ b/lib/ur/top.ur	Tue Feb 24 14:04:07 2009 -0500
@@ -7,6 +7,8 @@
                       -> tf [] -> tf r
 
 structure Folder = struct
+    fun fold K (r ::: {K}) (fl : folder r) = fl
+
     fun nil K (tf :: {K} -> Type)
             (f : nm :: Name -> v :: K -> r :: {K} -> tf r
                  -> [[nm] ~ r] => tf ([nm = v] ++ r))
--- a/lib/ur/top.urs	Tue Feb 24 13:50:39 2009 -0500
+++ b/lib/ur/top.urs	Tue Feb 24 14:04:07 2009 -0500
@@ -1,12 +1,14 @@
 (** Row folding *)
 
-con folder = K ==> fn r :: {K} =>
-                      tf :: ({K} -> Type)
-                      -> (nm :: Name -> v :: K -> r :: {K} -> tf r
-                          -> [[nm] ~ r] => tf ([nm = v] ++ r))
-                      -> tf [] -> tf r
+con folder :: K --> {K} -> Type
 
 structure Folder : sig
+    val fold : K --> r ::: {K} -> folder r
+               -> tf :: ({K} -> Type)
+               -> (nm :: Name -> v :: K -> r :: {K} -> tf r
+                   -> [[nm] ~ r] => tf ([nm = v] ++ r))
+               -> tf [] -> tf r
+
     val nil : K --> folder (([]) :: {K})
     val cons : K --> r ::: {K} -> nm :: Name -> v :: K
                -> [[nm] ~ r] => folder r -> folder ([nm = v] ++ r)