comparison demo/more/dnat.ur @ 1015:e47303e5d73d

Factor Dnat into separate module
author Adam Chlipala <adamc@hcoop.net>
date Sun, 25 Oct 2009 11:03:42 -0400
parents
children
comparison
equal deleted inserted replaced
1014:ea9f03ac2710 1015:e47303e5d73d
1 datatype t' = O | S of source t'
2 type t = source t'
3
4 val zero = source O
5
6 fun inc n =
7 v <- get n;
8 case v of
9 O =>
10 n' <- source O;
11 set n (S n')
12 | S n => inc n
13
14 fun dec n =
15 let
16 fun dec' last n =
17 v <- get n;
18 case v of
19 O => (case last of
20 None => return ()
21 | Some n' => set n' O)
22 | S n' => dec' (Some n) n'
23 in
24 dec' None n
25 end
26
27 fun render [ctx] [inp] [[Body] ~ ctx] (xml : xml ([Body] ++ ctx) inp []) n =
28 let
29 fun render n =
30 n <- signal n;
31 return (render' n)
32
33 and render' n =
34 case n of
35 O => <xml/>
36 | S n => <xml>
37 {xml}
38 <dyn signal={render n}/>
39 </xml>
40 in
41 <xml><dyn signal={render n}/></xml>
42 end