From 487f7affa283ac96326a6891c29c0800690b2c5f Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Tue, 24 Feb 2009 14:04:07 -0500 Subject: Make folders abstract --- demo/sum.ur | 4 ++-- lib/ur/top.ur | 2 ++ lib/ur/top.urs | 12 +++++++----- 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 {[sum Folder.nil {}]}
- {[sum (Folder.cons [#A] [()] (Folder.cons [#B] [()] Folder.nil)) {A = 0, B = 1}]}
- {[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}]}
+ {[sum (Folder.cons [#D] [()] ! (Folder.cons [#C] [()] ! (Folder.cons [#E] [()] ! Folder.nil))) {C = 2, D = 3, E = 4}]}
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) -- cgit v1.2.3