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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
open Fix.Indexing
module FSet (X : Index.Unsafe.T) = struct
module type S = sig
include SetSig.S1 with type 'a t = IntSet.t
and type 'a element = 'a X.t
val unsafe_to_indexset : 'a t -> 'b t
val unsafe_of_intset : IntSet.t -> 'a t
end
end
module FIntSet : FSet(Index.Unsafe.Int).S =
struct
type _element = int
type _t = IntSet.t
type 'a element = _element
type 'a t = _t
include (IntSet : SetSig.S0 with type element := _element and type t := _t)
let unsafe_to_indexset x = x
let unsafe_of_intset x = x
end
module IndexSet = Index.Unsafe.Coerce(FSet)(FIntSet)
include IndexSet
module CoerceSum(X : CARDINAL)(Y : CARDINAL) = struct
let coerce : X.n t -> (X.n, Y.n) Sum.n t = unsafe_to_indexset
end
let all n =
let i = Fix.Indexing.cardinal n in
if i = 0 then
empty
else
let a = Index.of_int n 0 in
let b = Index.of_int n (i - 1) in
init_interval a b
let init_from_set c f =
match Fix.Indexing.cardinal c with
| 0 -> empty
| n -> init_subset (Index.of_int c 0) (Index.of_int c (n - 1)) f
module FSetSet (X : Index.Unsafe.T) = struct
module type S = sig
include SetSig.StdSetS1 with type 'a t = IntSetSet.t
and type 'a elt = 'a X.t IndexSet.t
end
end
module FIntSetSet : FSetSet(Index.Unsafe.Int).S =
struct
type _elt = IntSet.t
type _t = IntSetSet.t
type 'a elt = _elt
type 'a t = _t
include (IntSetSet: Set.S with type elt := _elt and type t := _t)
end
module Set = Index.Unsafe.Coerce(FSetSet)(FIntSetSet)
module FSetMap (X : Index.Unsafe.T) = struct
module type S = sig
include SetSig.StdMapS1 with type ('n, 'a) t = 'a IntSetMap.t
and type 'n key = 'n X.t IndexSet.t
end
end
module FIntSetMap : FSetMap(Index.Unsafe.Int).S =
struct
type _key = IntSet.t
type 'a _t = 'a IntSetMap.t
type 'n key = _key
type ('n, 'a) t = 'a _t
include (IntSetMap: Map.S with type key := _key and type 'a t := 'a _t)
end
module Map = Index.Unsafe.Coerce(FSetMap)(FIntSetMap)