# HG changeset patch # User Adam Chlipala # Date 1295545392 18000 # Node ID 8631e9ed0ee8240306bc2f26ba7c150d03790a4b # Parent 82b204f20026b1c365b050bd96e89cd7f6d58aea queryXI and queryX1I diff -r 82b204f20026 -r 8631e9ed0ee8 lib/ur/top.ur --- a/lib/ur/top.ur Thu Jan 20 10:40:40 2011 -0500 +++ b/lib/ur/top.ur Thu Jan 20 12:43:12 2011 -0500 @@ -255,6 +255,30 @@ (fn fs acc => return {acc}{f fs}) +fun rev [a] (ls : list a) : list a = + let + fun rev' ls acc = + case ls of + [] => acc + | x :: ls => rev' ls (x :: acc) + in + rev' ls [] + end + +fun queryXI [tables ::: {{Type}}] [exps ::: {Type}] [ctx ::: {Unit}] [inp ::: {Type}] + [tables ~ exps] (q : sql_query [] [] tables exps) + (f : int -> $(exps ++ map (fn fields :: {Type} => $fields) tables) + -> xml ctx inp []) = + let + fun qxi ls i = + case ls of + [] => + | x :: ls => {f i x}{qxi ls (i+1)} + in + ls <- queryL q; + return (qxi ls 0) + end + fun queryX1 [nm ::: Name] [fs ::: {Type}] [ctx ::: {Unit}] [inp ::: {Type}] (q : sql_query [] [] [nm = fs] []) (f : $fs -> xml ctx inp []) = @@ -262,6 +286,19 @@ (fn fs acc => return {acc}{f fs.nm}) +fun queryX1I [nm ::: Name] [fs ::: {Type}] [ctx ::: {Unit}] [inp ::: {Type}] + (q : sql_query [] [] [nm = fs] []) + (f : int -> $fs -> xml ctx inp []) = + let + fun qx1i ls i = + case ls of + [] => + | x :: ls => {f i x.nm}{qx1i ls (i+1)} + in + ls <- queryL q; + return (qx1i ls 0) + end + 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) diff -r 82b204f20026 -r 8631e9ed0ee8 lib/ur/top.urs --- a/lib/ur/top.urs Thu Jan 20 10:40:40 2011 -0500 +++ b/lib/ur/top.urs Thu Jan 20 12:43:12 2011 -0500 @@ -164,11 +164,23 @@ -> xml ctx inp []) -> transaction (xml ctx inp []) +val queryXI : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit} -> inp ::: {Type} + -> [tables ~ exps] => + sql_query [] [] tables exps + -> (int -> $(exps ++ map (fn fields :: {Type} => $fields) tables) + -> xml ctx inp []) + -> transaction (xml ctx inp []) + val queryX1 : nm ::: Name -> fs ::: {Type} -> ctx ::: {Unit} -> inp ::: {Type} -> sql_query [] [] [nm = fs] [] -> ($fs -> xml ctx inp []) -> transaction (xml ctx inp []) +val queryX1I : nm ::: Name -> fs ::: {Type} -> ctx ::: {Unit} -> inp ::: {Type} + -> sql_query [] [] [nm = fs] [] + -> (int -> $fs -> xml ctx inp []) + -> transaction (xml ctx inp []) + val queryX' : tables ::: {{Type}} -> exps ::: {Type} -> ctx ::: {Unit} -> inp ::: {Type} -> [tables ~ exps] => sql_query [] [] tables exps