comparison lib/ur/top.ur @ 1076:dcf98ae3c48d

Allow same constructor shorthand for 'view' sig items as for 'table'
author Adam Chlipala <adamc@hcoop.net>
date Tue, 15 Dec 2009 11:11:49 -0500
parents d89f98f0b4bb
children 25d491287358
comparison
equal deleted inserted replaced
1075:0657e5adc938 1076:dcf98ae3c48d
222 -> xml ctx inp []) = 222 -> xml ctx inp []) =
223 query q 223 query q
224 (fn fs acc => return <xml>{acc}{f fs}</xml>) 224 (fn fs acc => return <xml>{acc}{f fs}</xml>)
225 <xml/> 225 <xml/>
226 226
227 fun queryX1 [nm ::: Name] [fs ::: {Type}] [ctx ::: {Unit}] [inp ::: {Type}]
228 (q : sql_query [nm = fs] [])
229 (f : $fs -> xml ctx inp []) =
230 query q
231 (fn fs acc => return <xml>{acc}{f fs.nm}</xml>)
232 <xml/>
233
227 fun queryX' [tables ::: {{Type}}] [exps ::: {Type}] [ctx ::: {Unit}] [inp ::: {Type}] 234 fun queryX' [tables ::: {{Type}}] [exps ::: {Type}] [ctx ::: {Unit}] [inp ::: {Type}]
228 [tables ~ exps] (q : sql_query tables exps) 235 [tables ~ exps] (q : sql_query tables exps)
229 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) 236 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables)
230 -> transaction (xml ctx inp [])) = 237 -> transaction (xml ctx inp [])) =
231 query q 238 query q
251 fun oneOrNoRows1 [nm ::: Name] [fs ::: {Type}] (q : sql_query [nm = fs] []) = 258 fun oneOrNoRows1 [nm ::: Name] [fs ::: {Type}] (q : sql_query [nm = fs] []) =
252 query q 259 query q
253 (fn fs _ => return (Some fs.nm)) 260 (fn fs _ => return (Some fs.nm))
254 None 261 None
255 262
256 fun oneOrNoRowsE1 [tab ::: Name] [nm ::: Name] [t ::: Type] [[tab] ~ [nm]] (q : sql_query [tab = []] [nm = t]) = 263 fun oneOrNoRowsE1 [tabs ::: {Unit}] [nm ::: Name] [t ::: Type] [tabs ~ [nm]] (q : sql_query (mapU [] tabs) [nm = t]) =
257 query q 264 query q
258 (fn fs _ => return (Some fs.nm)) 265 (fn fs _ => return (Some fs.nm))
259 None 266 None
260 267
261 fun oneRow [tables ::: {{Type}}] [exps ::: {Type}] 268 fun oneRow [tables ::: {{Type}}] [exps ::: {Type}]
262 [tables ~ exps] (q : sql_query tables exps) = 269 [tables ~ exps] (q : sql_query tables exps) =
263 o <- oneOrNoRows q; 270 o <- oneOrNoRows q;
264 return (case o of 271 return (case o of
265 None => error <xml>Query returned no rows</xml> 272 None => error <xml>Query returned no rows</xml>
266 | Some r => r) 273 | Some r => r)
274
275 fun oneRow1 [nm ::: Name] [fs ::: {Type}] (q : sql_query [nm = fs] []) =
276 o <- oneOrNoRows q;
277 return (case o of
278 None => error <xml>Query returned no rows</xml>
279 | Some r => r.nm)
267 280
268 fun oneRowE1 [tabs ::: {Unit}] [nm ::: Name] [t ::: Type] [tabs ~ [nm]] (q : sql_query (mapU [] tabs) [nm = t]) = 281 fun oneRowE1 [tabs ::: {Unit}] [nm ::: Name] [t ::: Type] [tabs ~ [nm]] (q : sql_query (mapU [] tabs) [nm = t]) =
269 o <- oneOrNoRows q; 282 o <- oneOrNoRows q;
270 return (case o of 283 return (case o of
271 None => error <xml>Query returned no rows</xml> 284 None => error <xml>Query returned no rows</xml>