comparison tests/rpcM.ur @ 642:4a125bbc602d

Conversion of functions to CPS, to facilitate ServerCall
author Adam Chlipala <adamc@hcoop.net>
date Sun, 08 Mar 2009 20:34:21 -0400
parents
children
comparison
equal deleted inserted replaced
641:b98f547a6a45 642:4a125bbc602d
1 datatype list t = Nil | Cons of t * list t
2
3 sequence s
4
5 fun main () : transaction page =
6 let
7 fun getIndices srcs =
8 case srcs of
9 Nil => return Nil
10 | Cons (src, srcs') =>
11 i <- nextval s;
12 set src i;
13 ls <- getIndices srcs';
14 return (Cons (i, ls))
15
16 fun show ls =
17 case ls of
18 Nil => <xml/>
19 | Cons (x, ls') => <xml>{[x]}<br/>{show ls'}</xml>
20 in
21 src1 <- source 0;
22 src2 <- source 1;
23 s <- source Nil;
24 return <xml><body>
25 <button value="Get It On!"
26 onclick={ns <- getIndices (Cons (src1, Cons (src2, Nil)));
27 set s ns}/><br/>
28 <br/>
29 #1: <dyn signal={n <- signal src1; return <xml>{[n]}</xml>}/><br/>
30 #2: <dyn signal={n <- signal src2; return <xml>{[n]}</xml>}/><br/>
31 Current: <dyn signal={ns <- signal s; return (show ns)}/>
32 </body></xml>
33 end