fun getOpt (t ::: Type) (o : option t) (v : t) : t =
case o of
None => v
| Some x => x
datatype color = Red | White | Blue
fun colorToString c =
case c of
Red => "R"
| White => "W"
| Blue => "B"
val show_color = mkShow colorToString
cookie int : int
cookie float : float
cookie string : string
cookie bool : bool
cookie pair : int * float
cookie option : option int
cookie color : color
fun main () : transaction page =
n <- getCookie int;
n <- return (getOpt n 7);
sn <- source 6;
f <- getCookie float;
f <- return (getOpt f 1.23);
sf <- source 4.56;
s <- getCookie string;
s <- return (getOpt s "Hi");
ss <- source "Bye";
b <- getCookie bool;
b <- return (getOpt b True);
sb <- source False;
p <- getCookie pair;
p <- return (getOpt p (1, 2.3));
sp <- source (4, 5.6);
o <- getCookie option;
o <- return (getOpt o (Some 1));
so <- source None;
c <- getCookie color;
c <- return (getOpt c White);
sc <- source Blue;
return
{[n]}}/>
CHANGE
{[f]}}/>
CHANGE
{[s]}}/>
CHANGE
{[b]}}/>
CHANGE
{[p.1]}, {[p.2]}}/>
CHANGE
return None
| Some x => return {[x]}}/>
CHANGE
{[c]}}/>
CHANGE