blob: 1a9851a78e40b7bb15092f0af63bcc623a176e5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
datatype rlist = Nil | Cons of {Data : source string,
NewData : source string,
Tail : source rlist}
fun showString ss =
s <- signal ss;
return <xml>{[s]}</xml>
fun show rls =
v <- signal rls;
show' v
and show' rl =
case rl of
Nil => return <xml/>
| Cons {Data = ss, NewData = ss', Tail = rls} => return <xml>
<dyn signal={showString ss}/>
<button value="Change to:" onclick={s <- get ss'; set ss s}/>
<ctextbox source={ss'}/><br/>
<dyn signal={show rls}/>
</xml>
fun main () =
head <- source Nil;
tailP <- source head;
data <- source "";
let
fun add () =
data <- get data;
data <- source data;
ndata <- source "";
tail <- get tailP;
tail' <- source Nil;
let
val cons = Cons {Data = data, NewData = ndata, Tail = tail'}
in
set tail cons;
set tailP tail';
head' <- get head;
case head' of
Nil => set head cons
| _ => return ()
end
in
return <xml><body>
<ctextbox source={data}/> <button value="Add" onclick={add ()}/><br/>
<br/>
<dyn signal={show head}/>
</body></xml>
end
|