aboutsummaryrefslogtreecommitdiffhomepage
path: root/demo/buffer.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-05 10:48:11 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-05 10:48:11 -0400
commit3b2a5f0903f59d0a58de4201ab4f16d34423bf25 (patch)
tree0a616d813984767dcc70ab5fe7b6409237851fc5 /demo/buffer.ur
parent2521a87414f0027e8fcef6b80fa414a5e0c20272 (diff)
Threads demo
Diffstat (limited to 'demo/buffer.ur')
-rw-r--r--demo/buffer.ur25
1 files changed, 25 insertions, 0 deletions
diff --git a/demo/buffer.ur b/demo/buffer.ur
new file mode 100644
index 00000000..27e2b805
--- /dev/null
+++ b/demo/buffer.ur
@@ -0,0 +1,25 @@
+datatype lines = End | Line of string * 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 (line, linesS) => <xml>{[line]}<br/><dyn signal={renderS linesS}/></xml>
+
+and renderS linesS =
+ lines <- signal linesS;
+ return (renderL lines)
+
+fun render t = renderS t.Head
+
+fun write t s =
+ oldTail <- get t.Tail;
+ newTail <- source End;
+ set oldTail (Line (s, newTail));
+ set t.Tail newTail