comparison tests/jsinj.ur @ 591:8f8771f32909

Injecting a float
author Adam Chlipala <adamc@hcoop.net>
date Thu, 01 Jan 2009 15:59:02 -0500
parents 57f476c934da
children a8be5a2068a5
comparison
equal deleted inserted replaced
590:57f476c934da 591:8f8771f32909
1 cookie int : int
2
3 fun getOpt (t ::: Type) (o : option t) (v : t) : t = 1 fun getOpt (t ::: Type) (o : option t) (v : t) : t =
4 case o of 2 case o of
5 None => v 3 None => v
6 | Some x => x 4 | Some x => x
7 5
6 cookie int : int
7 cookie float : float
8
8 fun main () : transaction page = 9 fun main () : transaction page =
9 n <- getCookie int; 10 n <- getCookie int;
10 sn <- source (getOpt n 7); 11 n <- return (getOpt n 7);
12 sn <- source 6;
13
14 f <- getCookie float;
15 f <- return (getOpt f 1.23);
16 sf <- source 4.56;
17
11 return <xml><body> 18 return <xml><body>
12 <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/> 19 <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/>
13 <a onclick={set sn 6}>CHANGE</a> 20 <a onclick={set sn n}>CHANGE</a><br/>
21
22 <dyn signal={f <- signal sf; return <xml>{[f]}</xml>}/>
23 <a onclick={set sf f}>CHANGE</a><br/>
14 </body></xml> 24 </body></xml>