diff tests/dynlines.ur @ 1800:38297294cf98

New NameJs phase, still needing some debugging
author Adam Chlipala <adam@chlipala.net>
date Thu, 02 Aug 2012 18:12:37 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/dynlines.ur	Thu Aug 02 18:12:37 2012 -0400
@@ -0,0 +1,33 @@
+datatype lines = End | Line of source lines
+
+type t = { Head : source lines, Tail : source (source lines) }
+
+val create =
+    head <- source End;
+    tail <- source head;
+    return {Head = head, Tail = tail}
+
+fun renderL lines =
+    case lines of
+        End => <xml/>
+      | Line linesS => <xml>X<br/><dyn signal={renderS linesS}/></xml>
+
+and renderS linesS =
+    lines <- signal linesS;
+    return (renderL lines)
+
+fun render t = renderS t.Head
+
+fun write t =
+    oldTail <- get t.Tail;
+    newTail <- source End;
+    set oldTail (Line newTail);
+    set t.Tail newTail
+
+fun main () : transaction page =
+    b <- create;
+
+    return <xml><body>
+      <button onclick={fn _ => write b}/>
+      <dyn signal={render b}/>
+    </body></xml>