comparison tests/jsinj.ur @ 597:d49d58a69877

Injected a non-special-case datatype
author Adam Chlipala <adamc@hcoop.net>
date Thu, 08 Jan 2009 10:30:14 -0500
parents d1ec54288b1a
children
comparison
equal deleted inserted replaced
596:d1ec54288b1a 597:d49d58a69877
18 fun delist ls : xbody = 18 fun delist ls : xbody =
19 case ls of 19 case ls of
20 Nil => <xml>Nil</xml> 20 Nil => <xml>Nil</xml>
21 | Cons (h, t) => <xml>{cdata h} :: {delist t}</xml> 21 | Cons (h, t) => <xml>{cdata h} :: {delist t}</xml>
22 22
23 datatype weird = Foo | Bar | Baz of string
24
25 fun weirdToString w =
26 case w of
27 Foo => "Foo"
28 | Bar => "Bar"
29 | Baz s => s
30
31 val show_weird = mkShow weirdToString
32
23 cookie int : int 33 cookie int : int
24 cookie float : float 34 cookie float : float
25 cookie string : string 35 cookie string : string
26 cookie bool : bool 36 cookie bool : bool
27 cookie pair : int * float 37 cookie pair : int * float
28 cookie option : option int 38 cookie option : option int
29 cookie color : color 39 cookie color : color
30 cookie list : list string 40 cookie list : list string
41 cookie weird : weird
31 42
32 fun main () : transaction page = 43 fun main () : transaction page =
33 n <- getCookie int; 44 n <- getCookie int;
34 n <- return (getOpt n 7); 45 n <- return (getOpt n 7);
35 sn <- source 6; 46 sn <- source 6;
60 71
61 l <- getCookie list; 72 l <- getCookie list;
62 l <- return (getOpt l (Cons ("A", Cons ("B", Nil)))); 73 l <- return (getOpt l (Cons ("A", Cons ("B", Nil))));
63 sl <- source Nil; 74 sl <- source Nil;
64 75
76 w <- getCookie weird;
77 w <- return (getOpt w (Baz "TADA!"));
78 sw <- source Foo;
79
65 return <xml><body> 80 return <xml><body>
66 <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/> 81 <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/>
67 <a onclick={set sn n}>CHANGE</a><br/> 82 <a onclick={set sn n}>CHANGE</a><br/>
68 83
69 <dyn signal={f <- signal sf; return <xml>{[f]}</xml>}/> 84 <dyn signal={f <- signal sf; return <xml>{[f]}</xml>}/>
86 <dyn signal={c <- signal sc; return <xml>{[c]}</xml>}/> 101 <dyn signal={c <- signal sc; return <xml>{[c]}</xml>}/>
87 <a onclick={set sc c}>CHANGE</a><br/> 102 <a onclick={set sc c}>CHANGE</a><br/>
88 103
89 <dyn signal={l <- signal sl; return <xml>{delist l}</xml>}/> 104 <dyn signal={l <- signal sl; return <xml>{delist l}</xml>}/>
90 <a onclick={set sl l}>CHANGE</a><br/> 105 <a onclick={set sl l}>CHANGE</a><br/>
106
107 <dyn signal={w <- signal sw; return <xml>{[w]}</xml>}/>
108 <a onclick={set sw w}>CHANGE</a><br/>
91 </body></xml> 109 </body></xml>