diff --git a/src/dune_pkg/diagnostics.ml b/src/dune_pkg/diagnostics.ml index 590859241c7..1c1c231d4d5 100644 --- a/src/dune_pkg/diagnostics.ml +++ b/src/dune_pkg/diagnostics.ml @@ -277,7 +277,7 @@ module Make (Results : S.SOLVER_RESULT) = struct type t = Component.t RoleMap.t - let find_component_ex role report = + let[@ocaml.warning "-32"] find_component_ex role report = match RoleMap.find report role with | Some c -> c | None -> diff --git a/src/dune_pkg/zeroinstall_solver.mli b/src/dune_pkg/diagnostics.mli similarity index 79% rename from src/dune_pkg/zeroinstall_solver.mli rename to src/dune_pkg/diagnostics.mli index 220e251d867..d542511faba 100644 --- a/src/dune_pkg/zeroinstall_solver.mli +++ b/src/dune_pkg/diagnostics.mli @@ -1,26 +1,8 @@ (* Copyright (C) 2020, Thomas Leonard See the README file for details, or visit http://0install.net. *) -module S = S - -(** Select a compatible set of components to run a program. - See [Zeroinstall.Solver] for the instantiation of this functor on the - actual 0install types. *) -module Make (Input : S.SOLVER_INPUT) : sig - module Output : S.SOLVER_RESULT with module Input = Input - - (** [do_solve model req] finds an implementation matching the given requirements, plus any other implementations needed - to satisfy its dependencies. - @param closest_match - adds a lowest-ranked (but valid) implementation ([Input.dummy_impl]) to - every interface, so we can always select something. Useful for diagnostics. - Note: always try without [closest_match] first, or it may miss a valid solution. - @return None if the solve fails (only happens if [closest_match] is false). *) - val do_solve : closest_match:bool -> Input.Role.t -> Output.t option Fiber.t -end - (** Explaining why a solve failed or gave an unexpected answer. *) -module Diagnostics (Result : S.SOLVER_RESULT) : sig +module Make (Result : S.SOLVER_RESULT) : sig (** An item of information to display for a component. *) module Note : sig type t = diff --git a/src/dune_pkg/opam_solver.ml b/src/dune_pkg/opam_solver.ml index 37da7dc1967..747e72a5588 100644 --- a/src/dune_pkg/opam_solver.ml +++ b/src/dune_pkg/opam_solver.ml @@ -559,8 +559,8 @@ module Solver = struct Input.virtual_role [ impl ] ;; - module Solver = Zeroinstall_solver.Make (Input) - module Diagnostics = Zeroinstall_solver.Diagnostics (Solver.Output) + module Solver = Solver_core.Make (Input) + module Diagnostics = Diagnostics.Make (Solver.Output) let solve context pkgs = let req = requirements ~context pkgs in diff --git a/src/dune_pkg/solver_core.ml b/src/dune_pkg/solver_core.ml index 270c1206cf6..bae411e0f38 100644 --- a/src/dune_pkg/solver_core.ml +++ b/src/dune_pkg/solver_core.ml @@ -10,6 +10,8 @@ open Fiber.O module Make (Model : S.SOLVER_INPUT) = struct (** We attach this data to each SAT variable. *) module SolverData = struct + [@@@ocaml.warning "-37"] + type t = (* If the SAT variable is True then we selected this... *) | ImplElem of Model.impl @@ -38,7 +40,7 @@ module Make (Model : S.SOLVER_INPUT) = struct ; dummy_impl : Model.impl option } - let is_dummy t impl = + let[@ocaml.warning "-32"] is_dummy t impl = match t.dummy_impl with | None -> false | Some dummy_impl -> dummy_impl == impl diff --git a/src/dune_pkg/solver_core.mli b/src/dune_pkg/solver_core.mli new file mode 100644 index 00000000000..abd2327f65f --- /dev/null +++ b/src/dune_pkg/solver_core.mli @@ -0,0 +1,15 @@ +(** Select a compatible set of components to run a program. + See [Zeroinstall.Solver] for the instantiation of this functor on the + actual 0install types. *) +module Make (Input : S.SOLVER_INPUT) : sig + module Output : S.SOLVER_RESULT with module Input = Input + + (** [do_solve model req] finds an implementation matching the given requirements, plus any other implementations needed + to satisfy its dependencies. + @param closest_match + adds a lowest-ranked (but valid) implementation ([Input.dummy_impl]) to + every interface, so we can always select something. Useful for diagnostics. + Note: always try without [closest_match] first, or it may miss a valid solution. + @return None if the solve fails (only happens if [closest_match] is false). *) + val do_solve : closest_match:bool -> Input.Role.t -> Output.t option Fiber.t +end diff --git a/src/dune_pkg/zeroinstall_solver.ml b/src/dune_pkg/zeroinstall_solver.ml deleted file mode 100644 index b6e110a797f..00000000000 --- a/src/dune_pkg/zeroinstall_solver.ml +++ /dev/null @@ -1,3 +0,0 @@ -module Make = Solver_core.Make -module Diagnostics = Diagnostics.Make -module S = S