diff tests/dlist.ur @ 601:7c3c21eb5b4c

Initial experiments with nested <dyn>
author Adam Chlipala <adamc@hcoop.net>
date Tue, 13 Jan 2009 15:17:11 -0500
parents
children b1064de2b1f9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dlist.ur	Tue Jan 13 15:17:11 2009 -0500
@@ -0,0 +1,22 @@
+datatype dlist = Nil | Cons of string * source dlist
+
+fun delist dl =
+    case dl of
+        Nil => <xml>[]</xml>
+      | Cons (x, s) => <xml>{[x]} :: {delistSource s}</xml>
+
+and delistSource s = <xml><dyn signal={dl <- signal s; return (delist dl)}/></xml>
+
+fun main () : transaction page =
+    ns <- source Nil;
+    s <- source ns;
+    tb <- source "";
+    return <xml><body>
+      <dyn signal={s <- signal s; return (delistSource s)}/><br/>
+      <br/>
+      <ctextbox source={tb}/>
+      <button value="Add" onclick={hd <- get tb;
+                                   tl <- get s;
+                                   s' <- source (Cons (hd, tl));
+                                   set s s'}/>
+    </body></xml>