adam@1619: functor Make(M : sig
adam@1619:                  type t
adam@1619:                  val read_t : read t
adam@1619:                  val show_t : show t
adam@1619:                  val num_t : num t
adam@1619:              end) = struct
adam@1619:     fun calculate (n1, n2) = return <xml><body>
adam@1619:       {[readError n1 / readError n2 : M.t]}<br/>
adam@1619:       {[readError n1 % readError n2 : M.t]}<br/>
adam@1619:     </body></xml>
adam@1619: 
adam@1619:     fun main () =
adam@1619:         s1 <- source "";
adam@1619:         s2 <- source "";
adam@1619:         s3 <- source "";
adam@1619:         s4 <- source "";
adam@1619:         return <xml><body>
adam@1619:           <h1>Client-side</h1>
adam@1619: 
adam@1619:           <ctextbox source={s1}/> / <ctextbox source={s2}/>
adam@1619:           <button value="=" onclick={n1 <- get s1;
adam@1619:                                      n2 <- get s2;
adam@1619:                                      set s3 (show (readError n1 / readError n2 : M.t));
adam@1619:                                      set s4 (show (readError n1 % readError n2 : M.t))}/>
adam@1619:           <dyn signal={n <- signal s3; return (txt n)}/>,
adam@1619:           <dyn signal={n <- signal s4; return (txt n)}/>
adam@1619: 
adam@1619:           <h1>Server-side</h1>
adam@1619: 
adam@1619:           <form>
adam@1619:             <textbox{#1}/> / <textbox{#2}/>
adam@1619:             <submit value="=" action={calculate}/>
adam@1619:           </form>
adam@1619:         </body></xml>
adam@1619: end
adam@1619: 
adam@1619: structure Int = Make(struct type t = int end)
adam@1619: structure Float = Make(struct type t = float end)
adam@1619: 
adam@1619: fun main () : transaction page = return <xml><body>
adam@1619:   <li><a link={Int.main ()}>Int</a></li>
adam@1619:   <li><a link={Float.main ()}>Float</a></li>
adam@1619: </body></xml>