Load_path(3)

🌸 Load_path(3) — the OCaml library page, bestie edition 🌸

hey bestie, this is the Load_path(3) page from the OCaml library. It’s giving “management of include directories,” and honestly? iconic. 💅


💖 NAME 💖

Load_path — Management of include directories. Short, sweet, slay. ✨

🧚 Module 🧚

Module Load_path
 : sig end

✨ Documentation ✨

okay so Load_path is a high-level interface to locating files in the load path. That path is constructed from -I and -H command line flags and a few other parameters. It makes the assumption that the contents of include directories doesn’t change during the execution of the compiler. like, the module is assuming peace and stability during the compiler run — do not be swapping files mid-compile, bestie. 🫶

Here’s the whole cast, in order, no skips, no cap:

🎀 The values and types, in order 🎀

  • val add_dir : hidden:bool -> string -> unit — Add a directory to the end of the load path (i.e. at lowest priority.) lowest priority means it’s at the back of the line, no cuts.
  • val remove_dir : string -> unit — Remove a directory from the load path.
  • val reset : unit -> unit — Remove all directories.
  • module Dir : sig end — yep, there’s a Dir submodule, and its signature is literally sig end.

The callback type is:

type auto_include_callback = (Dir.t -> string -> string option) -> string -> string

It’s the type of callback functions for init ~auto_include. iykyk.

  • val no_auto_include : auto_include_callback — No automatic directory inclusion: misses in the load path raise Not_found as normal. so if it’s not there, it’s not there.
  • val init : auto_include:auto_include_callback -> visible:string list -> hidden:string list -> unit — init ~visible ~hidden is the same as:
reset ();
List.iter add_dir (List.rev hidden);
List.iter add_dir (List.rev visible)
  • val auto_include_otherlibs : (string -> unit) -> auto_include_callback — auto_include_otherlibs alert is a callback function to be passed to Load_path.init and automatically adds -I +lib to the load path after calling alert lib . automatic otherlibs glow-up, periodt.
  • val get_path_list : unit -> string list — Return the list of directories passed to add_dir so far.

The paths record is:

type paths = {
 visible : string list ;
 hidden : string list ;
 }
  • val get_paths : unit -> paths — Return the directories passed to add_dir so far.
  • val find : string -> string — Locate a file in the load path. Raise Not_found if the file cannot be found. This function is optimized for the case where the filename is a basename, i.e. doesn’t contain a directory separator.
  • val find_normalized : string -> string — Same as find, but search also for normalized unit name (see Misc.normalized_unit_filename), i.e. if name is Foo.ml, allow /path/Foo.ml and /path/foo.ml to match. normalization ate, fr fr.

The visibility type is:

type visibility =
 | Visible
 | Hidden
  • val find_normalized_with_visibility : string -> string * visibility — Same as find_normalized, but also reports whether the cmi was found in a -I directory (Visible) or a -H directory (Hidden). the receipts are included, bestie.
  • val add : Dir.t -> unit — Deprecated. Old name for Load_path.append_dir.
🚨 bestie, add is deprecated — it’s the old name for Load_path.append_dir. Use the new name, okay? 💅
  • val append_dir : Dir.t -> unit — append_dir d adds d to the end of the load path (i.e. at lowest priority.)
  • val prepend_dir : Dir.t -> unit — prepend_dir d adds d to the start of the load path (i.e. at highest priority.) main character energy: front of the line.
  • val get_visible : unit -> Dir.t list — Same as get_paths (), except that it returns a Dir.t list, and doesn’t include the -H paths. visible only, hidden girlies not invited to this list.

okay that’s the whole page, every value and type accounted for, no details left on read. 💖

kisses, this page was generated by OCamldoc on 2026-06-22, and it’s page Load_path(3) — bye bestie! 🎀🦋🌸💜

📦 where this page comes from