blob: d898b86f632c0e4dc8322f6e1eabb7606fd32f16 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
module T = struct
type 'a t = unit
type 'a obs = ('a -> 'a)
let str s = ()
let num n = ()
let date d = ()
let bool b = ()
let observe () x = x
end
module R = struct
type 'a obs = Cell.Set.t -> Cell.Set.t
type 'a t = 'a obs
let cell (c:Cell.t) set = Cell.Set.add (Cell.to_pair c) set
let range c1 c2 set = begin
let x1, y1 = Cell.to_pair c1
and x2, y2 = Cell.to_pair c2 in
let f_x x acc = begin
let f_y y acc = begin
Cell.Set.add (x, y) acc
end in
Tools.fold_for f_y y1 y2 acc
end in
Tools.fold_for f_x x1 x2 set
end
let observe elem set = elem set
end
let observe f value = f value
let value v () = T.observe v
let ref r () = R.observe r
let call0 ident () acc = acc
let call1 ident p1 () acc = observe p1 acc
let call2 ident p1 p2 () acc = observe p2 (observe p1 acc)
let call3 ident p1 p2 p3 () acc = observe p3 (observe p2 (observe p1 acc))
let callN ident params () acc = List.fold_left (fun acc p -> observe p acc) acc params
let expression e () = e
type obs = Cell.Set.t -> Cell.Set.t
type t = unit
type repr = obs
|