File: lib_deps_info.ml

package info (click to toggle)
ocaml-dune 2.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,064 kB
  • sloc: ml: 70,777; lisp: 466; ansic: 241; sh: 209; makefile: 119; python: 38; cpp: 17; javascript: 6
file content (37 lines) | stat: -rw-r--r-- 654 bytes parent folder | download
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
open! Stdune

module Kind = struct
  type t =
    | Optional
    | Required

  let merge a b =
    match (a, b) with
    | Optional, Optional -> Optional
    | _ -> Required

  let of_optional b =
    if b then
      Optional
    else
      Required

  let to_dyn t =
    Dyn.String
      ( match t with
      | Optional -> "optional"
      | Required -> "required" )
end

type t = Kind.t Lib_name.Map.t

let merge a b =
  Lib_name.Map.merge a b ~f:(fun _ a b ->
      match (a, b) with
      | None, None -> None
      | x, None
      | None, x ->
        x
      | Some a, Some b -> Some (Kind.merge a b))

let to_dyn = Lib_name.Map.to_dyn Kind.to_dyn