Module B0caml_ocamlpath

OCAMLPATH support move to B0_care.

Logical paths

val classify_path : B0_std.Fpath.t -> [ `Concrete of B0_std.Fpath.t | `Logical of B0_std.Fpath.t ]

classify_path p is:

  • `Logical l if p starts with a '+'. l is p without the '+' or Fpath.v "." if that results in the empty string.
  • `Concrete d otherwise.

Logical paths are those that need to be looked up in OCAMLPATH.

val logical_path_root_name : B0_std.Fpath.t -> string option

logical_path_root_name d is:

  • Some r if classify_path d is `Logical d' and r the first non-dot segment of d'.
  • None otherwise.

OCAMLPATH lookup

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 ps 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.

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

dirs are the directories in the OCAMLPATH.

val ocaml_logical_dir : t -> B0_std.Fpath.t

ocaml_logical 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 logical_dirs : t -> (B0_std.Fpath.Set.t, string) Stdlib.result

logical_dirs is 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 ... ?".