comparison tests/jsinj.ur @ 596:d1ec54288b1a

Injected a polymorphic, recursive type
author Adam Chlipala <adamc@hcoop.net>
date Thu, 08 Jan 2009 10:15:45 -0500
parents 02c8ab9f3e8b
children d49d58a69877
comparison
equal deleted inserted replaced
595:02c8ab9f3e8b 596:d1ec54288b1a
11 | White => "W" 11 | White => "W"
12 | Blue => "B" 12 | Blue => "B"
13 13
14 val show_color = mkShow colorToString 14 val show_color = mkShow colorToString
15 15
16 datatype list a = Nil | Cons of a * list a
17
18 fun delist ls : xbody =
19 case ls of
20 Nil => <xml>Nil</xml>
21 | Cons (h, t) => <xml>{cdata h} :: {delist t}</xml>
22
16 cookie int : int 23 cookie int : int
17 cookie float : float 24 cookie float : float
18 cookie string : string 25 cookie string : string
19 cookie bool : bool 26 cookie bool : bool
20 cookie pair : int * float 27 cookie pair : int * float
21 cookie option : option int 28 cookie option : option int
22 cookie color : color 29 cookie color : color
30 cookie list : list string
23 31
24 fun main () : transaction page = 32 fun main () : transaction page =
25 n <- getCookie int; 33 n <- getCookie int;
26 n <- return (getOpt n 7); 34 n <- return (getOpt n 7);
27 sn <- source 6; 35 sn <- source 6;
48 56
49 c <- getCookie color; 57 c <- getCookie color;
50 c <- return (getOpt c White); 58 c <- return (getOpt c White);
51 sc <- source Blue; 59 sc <- source Blue;
52 60
61 l <- getCookie list;
62 l <- return (getOpt l (Cons ("A", Cons ("B", Nil))));
63 sl <- source Nil;
64
53 return <xml><body> 65 return <xml><body>
54 <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/> 66 <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/>
55 <a onclick={set sn n}>CHANGE</a><br/> 67 <a onclick={set sn n}>CHANGE</a><br/>
56 68
57 <dyn signal={f <- signal sf; return <xml>{[f]}</xml>}/> 69 <dyn signal={f <- signal sf; return <xml>{[f]}</xml>}/>
71 | Some x => return <xml>{[x]}</xml>}/> 83 | Some x => return <xml>{[x]}</xml>}/>
72 <a onclick={set so o}>CHANGE</a><br/> 84 <a onclick={set so o}>CHANGE</a><br/>
73 85
74 <dyn signal={c <- signal sc; return <xml>{[c]}</xml>}/> 86 <dyn signal={c <- signal sc; return <xml>{[c]}</xml>}/>
75 <a onclick={set sc c}>CHANGE</a><br/> 87 <a onclick={set sc c}>CHANGE</a><br/>
88
89 <dyn signal={l <- signal sl; return <xml>{delist l}</xml>}/>
90 <a onclick={set sl l}>CHANGE</a><br/>
76 </body></xml> 91 </body></xml>