Mercurial > urweb
comparison 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 |
comparison
equal
deleted
inserted
replaced
638:3ee6bb48f6e8 | 639:9da62680adc5 |
---|---|
1 datatype list t = Nil | Cons of t * list t | |
2 | |
3 table t : {A : int} | |
4 | |
5 fun main () : transaction page = | |
6 let | |
7 fun rows () = | |
8 query (SELECT * FROM t) | |
9 (fn r ls => return (Cons (r.T.A, ls))) | |
10 Nil | |
11 | |
12 fun show ls = | |
13 case ls of | |
14 Nil => <xml/> | |
15 | Cons (x, ls') => <xml>{[x]}<br/>{show ls'}</xml> | |
16 in | |
17 s <- source Nil; | |
18 return <xml><body> | |
19 <button value="Get It On!" | |
20 onclick={ls <- rows (); | |
21 set s ls}/><br/> | |
22 <br/> | |
23 Current: <dyn signal={ls <- signal s; return (show ls)}/> | |
24 </body></xml> | |
25 end |