view tests/dlist2.ur @ 1514:3c0803c1acd7

Backpedal on tutorial-motivated urweb-mode changes; add Basis.diffInSeconds and Basis.toSeconds
author Adam Chlipala <adam@chlipala.net>
date Fri, 22 Jul 2011 15:39:38 -0400
parents 1a9171e31fd1
children
line wrap: on
line source
datatype dlist = Nil | Cons of string * source dlist

fun delist dl =
    case dl of
        Nil => <xml>[]</xml>
      | Cons (x, s) => <xml>{[x]} <ctextbox/> :: {delistSource s}</xml>

and delistSource s = <xml><dyn signal={dl <- signal s; return (delist dl)}/></xml>

fun main () : transaction page =
    tail0 <- source Nil;
    tail <- source tail0;
    tb <- source "";
    return <xml><body>
      {delist (Cons ("ROOT", tail0))}
      <br/>
      <ctextbox source={tb}/>
      <button value="Add" onclick={hd <- get tb;
                                   tl <- source Nil;
                                   old <- get tail;

                                   set old (Cons (hd, tl));
                                   set tail tl}/>
      <button value="Reset" onclick={set tail0 Nil; set tail tail0}/>
    </body></xml>