comparison demo/buffer.ur @ 697:755a71c99be5

Threads demo
author Adam Chlipala <adamc@hcoop.net>
date Sun, 05 Apr 2009 10:48:11 -0400
parents
children
comparison
equal deleted inserted replaced
696:79a49c509007 697:755a71c99be5
1 datatype lines = End | Line of string * source lines
2
3 type t = { Head : source lines, Tail : source (source lines) }
4
5 val create =
6 head <- source End;
7 tail <- source head;
8 return {Head = head, Tail = tail}
9
10 fun renderL lines =
11 case lines of
12 End => <xml/>
13 | Line (line, linesS) => <xml>{[line]}<br/><dyn signal={renderS linesS}/></xml>
14
15 and renderS linesS =
16 lines <- signal linesS;
17 return (renderL lines)
18
19 fun render t = renderS t.Head
20
21 fun write t s =
22 oldTail <- get t.Tail;
23 newTail <- source End;
24 set oldTail (Line (s, newTail));
25 set t.Tail newTail