comparison lib/ur/top.ur @ 632:6c4643880df5

Demos compile again, with manual folders
author Adam Chlipala <adamc@hcoop.net>
date Tue, 24 Feb 2009 15:12:13 -0500
parents effa7d43aac3
children 24fd1edfcaa3
comparison
equal deleted inserted replaced
631:effa7d43aac3 632:6c4643880df5
72 72
73 fun foldUR (tf :: Type) (tr :: {Unit} -> Type) 73 fun foldUR (tf :: Type) (tr :: {Unit} -> Type)
74 (f : nm :: Name -> rest :: {Unit} 74 (f : nm :: Name -> rest :: {Unit}
75 -> [[nm] ~ rest] => 75 -> [[nm] ~ rest] =>
76 tf -> tr rest -> tr ([nm] ++ rest)) 76 tf -> tr rest -> tr ([nm] ++ rest))
77 (i : tr []) (r ::: {Unit}) (fold : folder r)= 77 (i : tr []) (r :: {Unit}) (fold : folder r)=
78 fold [fn r :: {Unit} => $(mapUT tf r) -> tr r] 78 fold [fn r :: {Unit} => $(mapUT tf r) -> tr r]
79 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc 79 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc
80 [[nm] ~ rest] r => 80 [[nm] ~ rest] r =>
81 f [nm] [rest] ! r.nm (acc (r -- nm))) 81 f [nm] [rest] ! r.nm (acc (r -- nm)))
82 (fn _ => i) 82 (fn _ => i)
83 83
84 fun foldUR2 (tf1 :: Type) (tf2 :: Type) (tr :: {Unit} -> Type) 84 fun foldUR2 (tf1 :: Type) (tf2 :: Type) (tr :: {Unit} -> Type)
85 (f : nm :: Name -> rest :: {Unit} 85 (f : nm :: Name -> rest :: {Unit}
86 -> [[nm] ~ rest] => 86 -> [[nm] ~ rest] =>
87 tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest)) 87 tf1 -> tf2 -> tr rest -> tr ([nm] ++ rest))
88 (i : tr []) (r ::: {Unit}) (fold : folder r) = 88 (i : tr []) (r :: {Unit}) (fold : folder r) =
89 fold [fn r :: {Unit} => $(mapUT tf1 r) -> $(mapUT tf2 r) -> tr r] 89 fold [fn r :: {Unit} => $(mapUT tf1 r) -> $(mapUT tf2 r) -> tr r]
90 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc 90 (fn (nm :: Name) (t :: Unit) (rest :: {Unit}) acc
91 [[nm] ~ rest] r1 r2 => 91 [[nm] ~ rest] r1 r2 =>
92 f [nm] [rest] ! r1.nm r2.nm (acc (r1 -- nm) (r2 -- nm))) 92 f [nm] [rest] ! r1.nm r2.nm (acc (r1 -- nm) (r2 -- nm)))
93 (fn _ _ => i) 93 (fn _ _ => i)
103 103
104 fun foldR K (tf :: K -> Type) (tr :: {K} -> Type) 104 fun foldR K (tf :: K -> Type) (tr :: {K} -> Type)
105 (f : nm :: Name -> t :: K -> rest :: {K} 105 (f : nm :: Name -> t :: K -> rest :: {K}
106 -> [[nm] ~ rest] => 106 -> [[nm] ~ rest] =>
107 tf t -> tr rest -> tr ([nm = t] ++ rest)) 107 tf t -> tr rest -> tr ([nm = t] ++ rest))
108 (i : tr []) (r ::: {K}) (fold : folder r) = 108 (i : tr []) (r :: {K}) (fold : folder r) =
109 fold [fn r :: {K} => $(map tf r) -> tr r] 109 fold [fn r :: {K} => $(map tf r) -> tr r]
110 (fn (nm :: Name) (t :: K) (rest :: {K}) (acc : _ -> tr rest) 110 (fn (nm :: Name) (t :: K) (rest :: {K}) (acc : _ -> tr rest)
111 [[nm] ~ rest] r => 111 [[nm] ~ rest] r =>
112 f [nm] [t] [rest] ! r.nm (acc (r -- nm))) 112 f [nm] [t] [rest] ! r.nm (acc (r -- nm)))
113 (fn _ => i) 113 (fn _ => i)
114 114
115 fun foldR2 K (tf1 :: K -> Type) (tf2 :: K -> Type) (tr :: {K} -> Type) 115 fun foldR2 K (tf1 :: K -> Type) (tf2 :: K -> Type) (tr :: {K} -> Type)
116 (f : nm :: Name -> t :: K -> rest :: {K} 116 (f : nm :: Name -> t :: K -> rest :: {K}
117 -> [[nm] ~ rest] => 117 -> [[nm] ~ rest] =>
118 tf1 t -> tf2 t -> tr rest -> tr ([nm = t] ++ rest)) 118 tf1 t -> tf2 t -> tr rest -> tr ([nm = t] ++ rest))
119 (i : tr []) (r ::: {K}) (fold : folder r) = 119 (i : tr []) (r :: {K}) (fold : folder r) =
120 fold [fn r :: {K} => $(map tf1 r) -> $(map tf2 r) -> tr r] 120 fold [fn r :: {K} => $(map tf1 r) -> $(map tf2 r) -> tr r]
121 (fn (nm :: Name) (t :: K) (rest :: {K}) 121 (fn (nm :: Name) (t :: K) (rest :: {K})
122 (acc : _ -> _ -> tr rest) [[nm] ~ rest] r1 r2 => 122 (acc : _ -> _ -> tr rest) [[nm] ~ rest] r1 r2 =>
123 f [nm] [t] [rest] ! r1.nm r2.nm (acc (r1 -- nm) (r2 -- nm))) 123 f [nm] [t] [rest] ! r1.nm r2.nm (acc (r1 -- nm) (r2 -- nm)))
124 (fn _ _ => i) 124 (fn _ _ => i)
141 r1 r2 acc => 141 r1 r2 acc =>
142 <xml>{f [nm] [t] [rest] ! r1 r2}{acc}</xml>) 142 <xml>{f [nm] [t] [rest] ! r1 r2}{acc}</xml>)
143 <xml/> 143 <xml/>
144 144
145 fun queryX (tables ::: {{Type}}) (exps ::: {Type}) (ctx ::: {Unit}) 145 fun queryX (tables ::: {{Type}}) (exps ::: {Type}) (ctx ::: {Unit})
146 (q : sql_query tables exps) [tables ~ exps] 146 [tables ~ exps] (q : sql_query tables exps)
147 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) 147 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables)
148 -> xml ctx [] []) = 148 -> xml ctx [] []) =
149 query q 149 query q
150 (fn fs acc => return <xml>{acc}{f fs}</xml>) 150 (fn fs acc => return <xml>{acc}{f fs}</xml>)
151 <xml/> 151 <xml/>
152 152
153 fun queryX' (tables ::: {{Type}}) (exps ::: {Type}) (ctx ::: {Unit}) 153 fun queryX' (tables ::: {{Type}}) (exps ::: {Type}) (ctx ::: {Unit})
154 (q : sql_query tables exps) [tables ~ exps] 154 [tables ~ exps] (q : sql_query tables exps)
155 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) 155 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables)
156 -> transaction (xml ctx [] [])) = 156 -> transaction (xml ctx [] [])) =
157 query q 157 query q
158 (fn fs acc => 158 (fn fs acc =>
159 r <- f fs; 159 r <- f fs;