summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-02-24 14:04:07 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-02-24 14:04:07 -0500
commit487f7affa283ac96326a6891c29c0800690b2c5f (patch)
treee356fff1dd9e40b0542313178974d74c1d3ff6c3
parent330dbb60d0cffe60d5257adbd82028737165bf63 (diff)
Make folders abstract
-rw-r--r--demo/sum.ur4
-rw-r--r--lib/ur/top.ur2
-rw-r--r--lib/ur/top.urs12
3 files changed, 11 insertions, 7 deletions
diff --git a/demo/sum.ur b/demo/sum.ur
index 566b7899..87b2967a 100644
--- a/demo/sum.ur
+++ b/demo/sum.ur
@@ -5,6 +5,6 @@ fun sum (fs ::: {Unit}) (fold : folder fs) (x : $(mapUT int fs)) =
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>
diff --git a/lib/ur/top.ur b/lib/ur/top.ur
index 5ce6ea9a..bfee2dfb 100644
--- a/lib/ur/top.ur
+++ b/lib/ur/top.ur
@@ -7,6 +7,8 @@ con folder = K ==> fn r :: {K} =>
-> 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))
diff --git a/lib/ur/top.urs b/lib/ur/top.urs
index 29b34b10..a9e5b6b3 100644
--- a/lib/ur/top.urs
+++ b/lib/ur/top.urs
@@ -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)