view tests/jsinj.ur @ 590:57f476c934da

Injecting an int
author Adam Chlipala <adamc@hcoop.net>
date Thu, 01 Jan 2009 15:11:17 -0500
parents
children 8f8771f32909
line wrap: on
line source
cookie int : int

fun getOpt (t ::: Type) (o : option t) (v : t) : t =
    case o of
        None => v
      | Some x => x

fun main () : transaction page =
    n <- getCookie int;
    sn <- source (getOpt n 7);
    return <xml><body>
      <dyn signal={n <- signal sn; return <xml>{[n]}</xml>}/>
      <a onclick={set sn 6}>CHANGE</a>
    </body></xml>