diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-03-08 13:41:55 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-03-08 13:41:55 -0400 |
commit | 5f77fc276c90321dec9e17ec483a1d8b11db3c96 (patch) | |
tree | 340a1e5251d1a16874ce49b5edf487714f45ff7b /tests | |
parent | b691dfb678a18667a623b45111683c480476051b (diff) |
RPC returning an option
Diffstat (limited to 'tests')
-rw-r--r-- | tests/rpcO.ur | 25 | ||||
-rw-r--r-- | tests/rpcO.urp | 5 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/rpcO.ur b/tests/rpcO.ur new file mode 100644 index 00000000..bc4b430e --- /dev/null +++ b/tests/rpcO.ur @@ -0,0 +1,25 @@ +table t : {A : int} + +fun main () : transaction page = + let + fun check () = + r <- oneRow (SELECT SUM(t.A) AS X FROM t); + return (if r.X < 0 then + (Some 3, None) + else + (None, Some "Hi")) + + fun show (t ::: Type) (_ : show t) (opt : option t) = + case opt of + None => <xml>None</xml> + | Some v => <xml>{[v]}</xml> + in + s <- source (None, None); + return <xml><body> + <button value="Get It On!" + onclick={r <- check (); + set s r}/><br/> + <br/> + Current: <dyn signal={p <- signal s; return <xml>{show p.1}, {show p.2}</xml>}/> + </body></xml> + end diff --git a/tests/rpcO.urp b/tests/rpcO.urp new file mode 100644 index 00000000..3a511580 --- /dev/null +++ b/tests/rpcO.urp @@ -0,0 +1,5 @@ +debug +sql rpcO.sql +database dbname=rpco + +rpcO |