annotate tests/jsinj.ur @ 593:f277f5faebcd

Injected a record
author Adam Chlipala <adamc@hcoop.net>
date Fri, 02 Jan 2009 12:42:39 -0500
parents a8be5a2068a5
children 55829473f6a7
rev   line source
adamc@590 1 fun getOpt (t ::: Type) (o : option t) (v : t) : t =
adamc@590 2 case o of
adamc@590 3 None => v
adamc@590 4 | Some x => x
adamc@590 5
adamc@591 6 cookie int : int
adamc@591 7 cookie float : float
adamc@592 8 cookie string : string
adamc@592 9 cookie bool : bool
adamc@593 10 cookie pair : int * float
adamc@591 11
adamc@590 12 fun main () : transaction page =
adamc@590 13 n <- getCookie int;
adamc@591 14 n <- return (getOpt n 7);
adamc@591 15 sn <- source 6;
adamc@591 16
adamc@591 17 f <- getCookie float;
adamc@591 18 f <- return (getOpt f 1.23);
adamc@591 19 sf <- source 4.56;
adamc@591 20
adamc@592 21 s <- getCookie string;
adamc@592 22 s <- return (getOpt s "Hi");
adamc@592 23 ss <- source "Bye";
adamc@592 24
adamc@592 25 b <- getCookie bool;
adamc@592 26 b <- return (getOpt b True);
adamc@592 27 sb <- source False;
adamc@592 28
adamc@593 29 p <- getCookie pair;
adamc@593 30 p <- return (getOpt p (1, 2.3));
adamc@593 31 sp <- source (4, 5.6);
adamc@593 32
adamc@590 33 return <xml><body>
adamc@590 34 <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/>
adamc@591 35 <a onclick={set sn n}>CHANGE</a><br/>
adamc@591 36
adamc@591 37 <dyn signal={f <- signal sf; return <xml>{[f]}</xml>}/>
adamc@591 38 <a onclick={set sf f}>CHANGE</a><br/>
adamc@592 39
adamc@592 40 <dyn signal={s <- signal ss; return <xml>{[s]}</xml>}/>
adamc@592 41 <a onclick={set ss s}>CHANGE</a><br/>
adamc@592 42
adamc@592 43 <dyn signal={b <- signal sb; return <xml>{[b]}</xml>}/>
adamc@592 44 <a onclick={set sb b}>CHANGE</a><br/>
adamc@593 45
adamc@593 46 <dyn signal={p <- signal sp; return <xml>{[p.1]}, {[p.2]}</xml>}/>
adamc@593 47 <a onclick={set sp p}>CHANGE</a><br/>
adamc@590 48 </body></xml>