Mercurial > urweb
comparison lib/ur/list.ur @ 1191:61c3139eab12
Subquery expressions
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 25 Mar 2010 15:44:24 -0400 |
parents | 52571ca9b777 |
children | 4c367c8f5b2d |
comparison
equal
deleted
inserted
replaced
1190:899875315bde | 1191:61c3139eab12 |
---|---|
242 in | 242 in |
243 app' | 243 app' |
244 end | 244 end |
245 | 245 |
246 fun mapQuery [tables ::: {{Type}}] [exps ::: {Type}] [t ::: Type] | 246 fun mapQuery [tables ::: {{Type}}] [exps ::: {Type}] [t ::: Type] |
247 [tables ~ exps] (q : sql_query tables exps) | 247 [tables ~ exps] (q : sql_query [] tables exps) |
248 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) -> t) = | 248 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) -> t) = |
249 ls <- query q | 249 ls <- query q |
250 (fn fs acc => return (f fs :: acc)) | 250 (fn fs acc => return (f fs :: acc)) |
251 []; | 251 []; |
252 return (rev ls) | 252 return (rev ls) |
253 | 253 |
254 fun mapQueryM [tables ::: {{Type}}] [exps ::: {Type}] [t ::: Type] | 254 fun mapQueryM [tables ::: {{Type}}] [exps ::: {Type}] [t ::: Type] |
255 [tables ~ exps] (q : sql_query tables exps) | 255 [tables ~ exps] (q : sql_query [] tables exps) |
256 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) -> transaction t) = | 256 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) -> transaction t) = |
257 ls <- query q | 257 ls <- query q |
258 (fn fs acc => v <- f fs; return (v :: acc)) | 258 (fn fs acc => v <- f fs; return (v :: acc)) |
259 []; | 259 []; |
260 return (rev ls) | 260 return (rev ls) |
261 | 261 |
262 fun mapQueryPartialM [tables ::: {{Type}}] [exps ::: {Type}] [t ::: Type] | 262 fun mapQueryPartialM [tables ::: {{Type}}] [exps ::: {Type}] [t ::: Type] |
263 [tables ~ exps] (q : sql_query tables exps) | 263 [tables ~ exps] (q : sql_query [] tables exps) |
264 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) -> transaction (option t)) = | 264 (f : $(exps ++ map (fn fields :: {Type} => $fields) tables) -> transaction (option t)) = |
265 ls <- query q | 265 ls <- query q |
266 (fn fs acc => v <- f fs; | 266 (fn fs acc => v <- f fs; |
267 return (case v of | 267 return (case v of |
268 None => acc | 268 None => acc |