Mercurial > urweb
comparison tests/rpcDD.ur @ 640:63b0bcacd535
RPC returning a default datatype
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Sun, 08 Mar 2009 13:28:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
639:9da62680adc5 | 640:63b0bcacd535 |
---|---|
1 datatype list t = Nil | OtherNil | 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 | OtherNil => <xml>That's impossible!</xml> | |
16 | Cons (x, ls') => <xml>{[x]}<br/>{show ls'}</xml> | |
17 in | |
18 s <- source Nil; | |
19 return <xml><body> | |
20 <button value="Get It On!" | |
21 onclick={ls <- rows (); | |
22 set s ls}/><br/> | |
23 <br/> | |
24 Current: <dyn signal={ls <- signal s; return (show ls)}/> | |
25 </body></xml> | |
26 end |