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
type t = Path.Set.t
let concat = Path.Set.union
let empty = Path.Set.empty
let reduce = List.fold_left concat empty
let singleton = Path.Set.singleton
let from_list = Path.Set.of_list
let equal = Path.Set.equal
let is_empty = Path.Set.is_empty
let add = Path.Set.add
let get_mtimes deps =
deps |> Path.Set.elements |> Eff.(List.traverse @@ mtime ~on:`Source)
let to_sexp deps =
deps |> Path.Set.to_list |> List.map Path.to_sexp |> Sexp.node
let all_path_nodes sexp node =
List.fold_left
(fun acc value ->
Result.bind acc (fun acc ->
value |> Path.from_sexp |> Result.map (fun p -> p :: acc)))
(Ok []) node
|> Result.map_error (fun _ -> Sexp.Invalid_sexp (sexp, "deps"))
let from_sexp sexp =
match sexp with
| Sexp.(Node paths) -> paths |> all_path_nodes sexp |> Result.map from_list
| _ -> Error (Sexp.Invalid_sexp (sexp, "deps"))
let pp ppf deps =
Format.fprintf ppf "Deps [@[%a@]]"
(Format.pp_print_list
~pp_sep:(fun ppf () -> Format.fprintf ppf ";@ ")
Path.pp)
(Path.Set.elements deps)