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
module type FUNCTOR = sig
type +'a t
end
type (+'a, 's) io
type 's scheduler = {
bind : 'a 'b. ('a, 's) io -> ('a -> ('b, 's) io) -> ('b, 's) io;
return : 'a. 'a -> ('a, 's) io;
}
module type SCHEDULER = sig
type +'a s
type t
external inj : 'a s -> ('a, t) io = "%identity"
external prj : ('a, t) io -> 'a s = "%identity"
end
module type MUTEX = sig
type +'a fiber
type t
val create : unit -> t
val lock : t -> unit fiber
val unlock : t -> unit
end
module type CONDITION = sig
type +'a fiber
type mutex
type t
val create : unit -> t
val wait : t -> mutex -> unit fiber
val signal : t -> unit
val broadcast : t -> unit
end
module type IO = sig
type +'a t
module Mutex : MUTEX with type 'a fiber = 'a t
module Condition :
CONDITION with type 'a fiber = 'a t and type mutex = Mutex.t
val bind : 'a t -> ('a -> 'b t) -> 'b t
val return : 'a -> 'a t
val detach : (unit -> 'a) -> 'a t
val parallel_map : f:('a -> 'b t) -> 'a list -> 'b list t
val parallel_iter : f:('a -> unit t) -> 'a list -> unit t
end
module Make (T : FUNCTOR) : SCHEDULER with type 'a s = 'a T.t = struct
type 'a s = 'a T.t
type t
external inj : 'a -> 'b = "%identity"
external prj : 'a -> 'b = "%identity"
end
module type UID = sig
type t
type ctx
val empty : ctx
val get : ctx -> t
val feed : ctx -> ?off:int -> ?len:int -> Bigstringaf.t -> ctx
val equal : t -> t -> bool
val compare : t -> t -> int
val length : int
val of_raw_string : string -> t
val to_raw_string : t -> string
val pp : t Fmt.t
val null : t
end
type kind = [ `A | `B | `C | `D ]
let _max_depth = 60