Module Melange_compiler_libs.Load_path

Management of include directories.

This module offers a high level interface to locating files in the load path, which is constructed from -I 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.

let add_dir: string => unit;

Add a directory to the end of the load path (i.e. at lowest priority.)

let remove_dir: string => unit;

Remove a directory from the load path

let reset: unit => unit;

Remove all directories

module Dir: { ... };
type auto_include_callback = (Dir.t => string => option(string)) => string => string;

The type of callback functions on for init ~auto_include

let no_auto_include: auto_include_callback;

No automatic directory inclusion: misses in the load path raise Not_found as normal.

let init: auto_include:auto_include_callback => list(string) => unit;

init l is the same as reset (); List.iter add_dir (List.rev l)

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

let get_paths: unit => list(string);

Return the list of directories passed to add_dir so far.

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

let find_uncap: string => string;

Same as find, but search also for uncapitalized name, i.e. if name is Foo.ml, allow /path/Foo.ml and /path/foo.ml to match.

let add: Dir.t => unit;

Old name for append_dir

  • deprecated
let append_dir: Dir.t => unit;

append_dir d adds d to the end of the load path (i.e. at lowest priority.

let prepend_dir: Dir.t => unit;

prepend_dir d adds d to the start of the load path (i.e. at highest priority.

let get: unit => list(Dir.t);

Same as get_paths (), except that it returns a Dir.t list.