blob: 8d8095e7412e7d3d9bf9b3437ea97211ee0cc2e0 (
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
|
datatype t' = O | S of source t'
type t = source t'
val zero = source O
fun inc n =
v <- get n;
case v of
O =>
n' <- source O;
set n (S n')
| S n => inc n
fun dec n =
let
fun dec' last n =
v <- get n;
case v of
O => (case last of
None => return ()
| Some n' => set n' O)
| S n' => dec' (Some n) n'
in
dec' None n
end
fun render [ctx] [inp] [[Body] ~ ctx] (xml : xml ([Body] ++ ctx) inp []) n =
let
fun render n =
n <- signal n;
return (render' n)
and render' n =
case n of
O => <xml/>
| S n => <xml>
{xml}
<dyn signal={render n}/>
</xml>
in
<xml><dyn signal={render n}/></xml>
end
|