1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162moduleMake(Context:S.CONTEXT)=structmoduleInput=Model.Make(Context)letrequirements~contextpkgs=letrole=matchpkgswith|[pkg]->Input.rolecontextpkg|pkgs->letimpl=Input.virtual_impl~context~depends:pkgs()inInput.virtual_role[impl]in{Input.role;command=None}moduleSolver=Zeroinstall_solver.Make(Input)moduleDiagnostics=Zeroinstall_solver.Diagnostics(Solver.Output)typet=Context.ttypeselections=Solver.Output.ttypediagnostics=Input.requirements(* So we can run another solve *)letsolvecontextpkgs=letreq=requirements~contextpkgsinmatchSolver.do_solve~closest_match:falsereqwith|Somesels->Oksels|None->Errorreqletpp_shortf(impl:Input.impl)=Input.pp_implfimplletrecpartitionf=function|[]->[],[]|x::xs->letys,zs=partitionfxsinmatchfxwith|`Lefty->(y::ys),zs|`Rightz->ys,(z::zs)letpp_rolemap~verbosefreasons=letshort,long=reasons|>Solver.Output.RoleMap.bindings|>partition(fun(_role,component)->matchDiagnostics.Component.selected_implcomponentwith|SomeimplwhenDiagnostics.Component.notescomponent=[]->`Leftimpl|_->`Rightcomponent)inletpp_itemfc=Fmt.pff"- @[%a@]"(Diagnostics.Component.pp~verbose)cinFmt.pff"Selected: @[<hov>%a@]@,%a"(Fmt.(list~sep:sp)pp_short)short(Fmt.(list~sep:cut)pp_item)longletdiagnostics?(verbose=false)req=Solver.do_solvereq~closest_match:true|>Option.get|>Diagnostics.of_result|>Fmt.strf"Can't find all required versions.@\n@[<v0>%a@]"(pp_rolemap~verbose)letpackages_of_resultsels=sels|>Solver.Output.to_map|>Solver.Output.RoleMap.to_seq|>List.of_seq|>List.filter_map(fun(_role,sel)->Input.version(Solver.Output.unwrapsel))end