diff tests/rpcDO.ur @ 639:9da62680adc5

RPC returning an option datatype
author Adam Chlipala <adamc@hcoop.net>
date Sun, 08 Mar 2009 12:54:07 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/rpcDO.ur	Sun Mar 08 12:54:07 2009 -0400
@@ -0,0 +1,25 @@
+datatype list t = Nil | Cons of t * list t
+
+table t : {A : int}
+
+fun main () : transaction page =
+    let
+        fun rows () =
+            query (SELECT * FROM t)
+            (fn r ls => return (Cons (r.T.A, ls)))
+            Nil
+
+        fun show ls =
+            case ls of
+                Nil => <xml/>
+              | Cons (x, ls') => <xml>{[x]}<br/>{show ls'}</xml>
+    in
+        s <- source Nil;
+        return <xml><body>
+          <button value="Get It On!"
+                  onclick={ls <- rows ();
+                           set s ls}/><br/>
+          <br/>
+          Current: <dyn signal={ls <- signal s; return (show ls)}/>
+        </body></xml>
+    end