annotate tests/query.ur @ 253:7f6620853c36

Monoized a WHERE clause with a comparison
author Adam Chlipala <adamc@hcoop.net>
date Sun, 31 Aug 2008 14:27:01 -0400
parents 326fb4686f60
children f8d9395575ec
rev   line source
adamc@253 1 table t1 : {A : int, B : string, C : float, D : bool}
adamc@243 2 table t2 : {A : float, D : int}
adamc@243 3
adamc@243 4 datatype list a = Nil | Cons of a * list a
adamc@243 5
adamc@253 6 (*val q1 = (SELECT * FROM t1)*)
adamc@253 7 val q1 = (SELECT * FROM t1 WHERE t1.A = 0)
adamc@253 8
adamc@253 9 val r1 : transaction (list {A : int, B : string, C : float, D : bool}) =
adamc@243 10 query q1
adamc@251 11 (fn fs acc => return (Cons (fs.T1, acc)))
adamc@243 12 Nil
adamc@243 13
adamc@249 14 val r2 : transaction string =
adamc@243 15 ls <- r1;
adamc@243 16 return (case ls of
adamc@249 17 Nil => "Problem"
adamc@249 18 | Cons ({B = b, ...}, _) => b)
adamc@249 19
adamc@249 20 val main : unit -> transaction page = fn () =>
adamc@249 21 s <- r2;
adamc@249 22 return <html><body>
adamc@249 23 {cdata s}
adamc@249 24 </body></html>