package codept-lib

  1. Overview
  2. Docs
Alternative ocaml dependency analyzer

Install

Dune Dependency

Authors

Maintainers

Sources

codept-0.12.1.tbz
sha256=381d300bad1d526d241414d74c670853896547c10efe69f56a1838f00264f69b
sha512=1517e482a60ed9c76cceff0f64ef73b28a667800fb5bd0a0f142487bbd9c36aadc9534b70de1d261027bd7164dc80ac620d8c04cc94990f627db49e96f786ae5

doc/codept-lib/Unitname/index.html

Module UnitnameSource

The Unit name is the name of a module which can be represented by a file. The unit name transforms the given file path into a Modname.t and keep the file path internally.

By this way, an t as two views:

  • as a file path (where the module is located into the file-system)
  • as a module name
Sourcetype t

Type of an unit name.

Sourceval modulize : string -> t

modulize filename makes a new t which contains the given filename and modulize it: it removes the extension (if it exists), it capitalises the first letter of the filename's Filename.basename and replace any wrong characters by '_'.

For instance:

  • "foo.ml" => "Foo"
  • "Foo" => "Foo"
  • "foo'.ml" => "Foo_"
  • "lib/foo.ml" => "Foo"
  • "foo-bar.ml" => "Foo-bar"

We assert that:

  # let v = Unitname.modulize "foo.ml" ;;
  # assert (Stdlib.compare v Unitname.(modulize (filepath v)) = 0) ;;
Sourceval modname : t -> Modname.t
Sourceval filename : t -> string

filename v returns the filename of the given unit name. The filename is the Filename.basename of the filepath given to construct v with modulize.

Sourceval filepath : t -> string

filepath v returns the filepath of the given unit name. The file path is the one used to construct v with modulize.

Sourceval pp : t Pp.t
Sourceval pp_as_modname : t Pp.t
Sourceval pp_as_filepath : t Pp.t
Sourceval reflect : t Pp.t
Sourceval compare_as_modnames : t -> t -> int

compare_as_modnames a b compares a and b from their modname's views. For instance,

  # let a = Unitname.modulize "foo/a.ml" ;;
  # let b = Unitname.modulize "bar/a.ml" ;;
  # Unitname.compare_as_modnames a b ;;
  - : int = 0
Sourceval change_file_extension : (string -> string) -> t -> t

change_file_extension f t tries to replace the current extension of the given t (the filename view) by something else returned by f. If t has no extension, we return it unchanged. Otherwise, we call f and give to it the current extension.

NOTE: The modname view is unchanged in any cases:

  # let v0 = Unitname.modulize "foo.ml" ;;
  # let v1 = Unitname.change_file_extension (fun _ -> "mli") v0 ;;
  # assert (Modname.compare (Unitname.modname v0) (Unitname.modname v1) = 0) ;;

However, v0 and v1 are not equal anymore.

Sourcemodule Map : Map.S with type key = t
Sourcemodule Set : Set.S with type elt = t
OCaml

Innovation. Community. Security.