diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-12-15 11:11:49 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-12-15 11:11:49 -0500 |
commit | ab13bbf764595fe6c01fcb5fe61bdf464d77f7fe (patch) | |
tree | a6950e374ba47268bc2bc5ee4cb14dd5a6f3d5b1 /lib/ur/top.ur | |
parent | 6179a09d47c5af4db1ac41d00b8cb7ec36741c3e (diff) |
Allow same constructor shorthand for 'view' sig items as for 'table'
Diffstat (limited to 'lib/ur/top.ur')
-rw-r--r-- | lib/ur/top.ur | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/ur/top.ur b/lib/ur/top.ur index 78a799b1..9a27f6b2 100644 --- a/lib/ur/top.ur +++ b/lib/ur/top.ur @@ -224,6 +224,13 @@ fun queryX [tables ::: {{Type}}] [exps ::: {Type}] [ctx ::: {Unit}] [inp ::: {Ty (fn fs acc => return <xml>{acc}{f fs}</xml>) <xml/> +fun queryX1 [nm ::: Name] [fs ::: {Type}] [ctx ::: {Unit}] [inp ::: {Type}] + (q : sql_query [nm = fs] []) + (f : $fs -> xml ctx inp []) = + query q + (fn fs acc => return <xml>{acc}{f fs.nm}</xml>) + <xml/> + fun queryX' [tables ::: {{Type}}] [exps ::: {Type}] [ctx ::: {Unit}] [inp ::: {Type}] [tables ~ exps] (q : sql_query tables exps) (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) @@ -253,7 +260,7 @@ fun oneOrNoRows1 [nm ::: Name] [fs ::: {Type}] (q : sql_query [nm = fs] []) = (fn fs _ => return (Some fs.nm)) None -fun oneOrNoRowsE1 [tab ::: Name] [nm ::: Name] [t ::: Type] [[tab] ~ [nm]] (q : sql_query [tab = []] [nm = t]) = +fun oneOrNoRowsE1 [tabs ::: {Unit}] [nm ::: Name] [t ::: Type] [tabs ~ [nm]] (q : sql_query (mapU [] tabs) [nm = t]) = query q (fn fs _ => return (Some fs.nm)) None @@ -265,6 +272,12 @@ fun oneRow [tables ::: {{Type}}] [exps ::: {Type}] None => error <xml>Query returned no rows</xml> | Some r => r) +fun oneRow1 [nm ::: Name] [fs ::: {Type}] (q : sql_query [nm = fs] []) = + o <- oneOrNoRows q; + return (case o of + None => error <xml>Query returned no rows</xml> + | Some r => r.nm) + fun oneRowE1 [tabs ::: {Unit}] [nm ::: Name] [t ::: Type] [tabs ~ [nm]] (q : sql_query (mapU [] tabs) [nm = t]) = o <- oneOrNoRows q; return (case o of |