diff tests/crud.ur @ 334:9601c717d2f3

queryX
author Adam Chlipala <adamc@hcoop.net>
date Sat, 13 Sep 2008 19:49:53 -0400
parents 02d15d81ae9b
children 34847732cefc
line wrap: on
line diff
--- a/tests/crud.ur	Sat Sep 13 14:58:57 2008 -0400
+++ b/tests/crud.ur	Sat Sep 13 19:49:53 2008 -0400
@@ -14,10 +14,9 @@
 open constraints M
 val tab = M.tab
 
-fun list () =
-        rows <- query (SELECT * FROM tab AS T)
-                (fn (fs : {T : $([Id = int] ++ M.cols)}) acc => return <body>
-                        {acc}
+fun main () : transaction page =
+        rows <- queryX (SELECT * FROM tab AS T)
+                (fn (fs : {T : $([Id = int] ++ M.cols)}) => <body>
                         <tr>
                                 <td>{txt _ fs.T.Id}</td>
                                 {foldTRX2 [idT] [colMeta'] [tr]
@@ -28,13 +27,13 @@
                                                 </tr>)
                                         [M.cols] (fs.T -- #Id) M.cols}
                         </tr>
-                </body>) <body></body>;
+                </body>);
         return <html><head>
-                <title>List</title>
+                <title>{cdata M.title}</title>
 
                 </head><body>
 
-                <h1>List</h1>
+                <h1>{cdata M.title}</h1>
 
                 <table border={1}>
                 <tr> <th>ID</th> </tr>
@@ -42,12 +41,4 @@
                 </table>
         </body></html>
 
-fun main () : transaction page = return <html><head>
-        <title>{cdata M.title}</title>
-        </head><body>
-        <h1>{cdata M.title}</h1>
-
-        <li> <a link={list ()}>List all rows</a></li>
-</body></html>
-
 end