Module Brzo_b0_ocamlpath

OCAMLPATH support move to B0_care.


type t

The type for OCAMLPATH. Conceptually it's just a list of directories but for legacy reasons we need to carry a bit more information.

val get : ?⁠search:B0_std.Fpath.t list -> B0_std.Fpath.t list option -> (t, string) Stdlib.result

get ocamlpath is Ok p if ocamlpath is Some ps and otherwise:

  • If the OCAMLPATH environment variable is defined, its contents parsed according to Fpath.list_of_search_path.
  • If the opam tool is available [$(opam var lib); $(ocamlc -where)] or [$(opam var lib)] if $(ocamlc -where) is included in it.
  • If the opam tool is not available $(ocamlc -where)

search is given to Os.Cmd.find to lookup ocamlc and opam. In the last two cases the "ocaml" library name is mapped to ocamlc -where.

val root_dirs : t -> B0_std.Fpath.t list

dirs are the root directories of the OCAMLPATH.

val ocaml_lib_path : t -> B0_std.Fpath.t

ocaml_lib_path is the path to the directory that should be called "ocaml" in the OCAMLPATH. For systems installs where packages are installed in ocamlc -where (OCAMLPATH is undefined), ocamlc -where is in dirs but "ocaml" cannot be resolved by looking up dirs. This is the resolution that should be used for "ocaml".

val libs : t -> (B0_std.Fpath.Set.t, string) Stdlib.result

libs ocamlpath are the library names available in ocamlpath. This is the set of

the domain of logical directories in ocamlpath on the current file system. That is the set of directories DIR that can be specified as +DIR. The set has them without the +.

Logical suggestions

val logical_dir_suggestions : logical_dirs:B0_std.Fpath.Set.t -> B0_std.Fpath.t -> B0_std.Fpath.t list option

dir_suggestions ~dirs dir are suggestions to correct an unfound logical directory dir in logical_dirs for example obtained via logical_dirs.

val pp_did_you_mean_logical_dirs : B0_std.Fpath.t list B0_std.Fmt.t

pp_did_you_mean_logical_dirs suggests a logical directory spell check. Formats a starting Fmt.cut followed by a boxed sentence of the form "Did you mean ... ?".