Module Nametab

This module contains the tables for globalization.

These globalization tables associate internal object references to qualified names (qualid). There are three classes of names:

Most functions in this module fall into one of the following categories:

module GlobDirRef : sig ... end

to this type are mapped DirPath.t's in the nametab

exception GlobalizationError of Libnames.qualid
val error_global_not_found : info:Exninfo.info -> Libnames.qualid -> 'a

Raises a globalization error

Register visibility of things

The visibility can be registered either

type visibility =
| Until of int
| Exactly of int
val map_visibility : (int -> int) -> visibility -> visibility
Nametab generic APIs
module type NAMETAB = sig ... end

Common APIs on name tables.

module type WarnedTab = sig ... end

NAMETAB extended with warnings associated to some of the elements.

Core nametabs

NAMETAB extended with warnings associated to some of the elements.

module Univs : NAMETAB with type elt = Univ.UGlobal.t

Common APIs on name tables.

module Quality : NAMETAB with type elt = Sorts.QGlobal.t

Common APIs on name tables.

module ModTypes : NAMETAB with type elt = Names.ModPath.t

Module types, modules and open modules/modtypes/sections form three separate name spaces (maybe this will change someday)

module Modules : NAMETAB with type elt = Names.ModPath.t

Common APIs on name tables.

module OpenMods : NAMETAB with type elt = GlobDirRef.t

Common APIs on name tables.

Specializations for extended references

These functions operate on XRefs but are about a subset of extended_global_reference for convenience.

val locate_all : Libnames.qualid -> Names.GlobRef.t list
val locate_constant : Libnames.qualid -> Names.Constant.t
val locate_abbreviation : Libnames.qualid -> Globnames.abbreviation
val remove_abbreviation : Libnames.full_path -> Globnames.abbreviation -> unit
val global_of_path : Libnames.full_path -> Names.GlobRef.t
val path_of_global : Names.GlobRef.t -> Libnames.full_path
val path_of_abbreviation : Globnames.abbreviation -> Libnames.full_path
val shortest_qualid_of_global : ?loc:Loc.t -> Names.Id.Set.t -> Names.GlobRef.t -> Libnames.qualid
val shortest_qualid_of_abbreviation : ?loc:Loc.t -> Names.Id.Set.t -> Globnames.abbreviation -> Libnames.qualid
val pr_global_env : Names.Id.Set.t -> Names.GlobRef.t -> Pp.t

Printing of global references using names as short as possible.

  • raises Not_found

    when the reference is not in the global tables.

Returns in particular the dirpath or the basename of the full path associated to global reference

val dirpath_of_global : Names.GlobRef.t -> Names.DirPath.t
val basename_of_global : Names.GlobRef.t -> Names.Id.t

These functions globalize user-level references into global references, like locate and co, but raise GlobalizationError for unbound qualid and UserError for type mismatches (eg global_inductive when the qualid is bound to a constructor)

val global_inductive : Libnames.qualid -> Names.inductive
These functions declare (resp. return) the source location of the object if known
val set_cci_src_loc : Globnames.extended_global_reference -> Loc.t -> unit
val cci_src_loc : Globnames.extended_global_reference -> Loc.t option
Nametab generators
module type ValueType = sig ... end
module type StateInfo = sig ... end

Necessary data to declare the imperative state for a nametab.

module EasyNoWarn (M : sig ... end) () : NAMETAB with type elt = M.t

Generate a nametab, without warning support.

module type WarnInfo = sig ... end
module MakeWarned (M : NAMETAB) (W : WarnInfo with type elt = M.elt) () : WarnedTab with type elt = M.elt and type warning_data := W.data

Add warning support to an existing nametab.

module type SimpleWarnS = sig ... end
module Easy (M : sig ... end) () : WarnedTab with type elt = M.t and type warning_data := M.t UserWarn.with_qf

Generate a nametab with simple warning support (UserWarn.create_depr_and_user_warnings_qf).

legacy APIs
val push_modtype : visibility -> Libnames.full_path -> Names.ModPath.t -> unit
val push_module : visibility -> Libnames.full_path -> Names.ModPath.t -> unit
val push_dir : visibility -> Libnames.full_path -> GlobDirRef.t -> unit
val push_universe : visibility -> Libnames.full_path -> Univ.UGlobal.t -> unit

Deprecation and user warn info

The following functions perform globalization of qualified names

These functions globalize a (partially) qualified name or fail with Not_found

val locate_modtype : Libnames.qualid -> Names.ModPath.t
val locate_dir : Libnames.qualid -> GlobDirRef.t
val locate_module : Libnames.qualid -> Names.ModPath.t
val locate_section : Libnames.qualid -> Libnames.full_path
val locate_universe : Libnames.qualid -> Univ.UGlobal.t

These functions locate all global references with a given suffix; if qualid is valid as such, it comes first in the list

val locate_extended_all : Libnames.qualid -> Globnames.extended_global_reference list
val locate_extended_all_dir : Libnames.qualid -> GlobDirRef.t list
val locate_extended_all_modtype : Libnames.qualid -> Names.ModPath.t list
val locate_extended_all_module : Libnames.qualid -> Names.ModPath.t list
val completion_canditates : Libnames.qualid -> Globnames.extended_global_reference list

Experimental completion support, API is _unstable_

completion_canditates qualid will return the list of global references that have qualid as a prefix. UI usually will want to compose this with shortest_qualid_of_global

Mapping a full path to a global reference

These functions tell if the given absolute name is already taken
val exists_cci : Libnames.full_path -> bool
val exists_modtype : Libnames.full_path -> bool
val exists_module : Libnames.full_path -> bool
val exists_dir : Libnames.full_path -> bool
val exists_universe : Libnames.full_path -> bool
These functions locate qualids into full user names
val full_name_modtype : Libnames.qualid -> Libnames.full_path
val full_name_module : Libnames.qualid -> Libnames.full_path
val full_name_open_mod : Libnames.qualid -> Libnames.full_path
Reverse lookup

Finding user names corresponding to the given internal name

Returns the full path bound to a global reference or syntactic definition, and the (full) dirpath associated to a module path

val path_of_module : Names.ModPath.t -> Libnames.full_path
val path_of_modtype : Names.ModPath.t -> Libnames.full_path
val path_of_universe : Univ.UGlobal.t -> Libnames.full_path

A universe_id might not be registered with a corresponding user name.

  • raises Not_found

    if the universe was not introduced by the user.

The shortest_qualid functions given an object with user_name Mylib.A.B.x, try to find the shortest among x, B.x, A.B.x and Mylib.A.B.x that denotes the same object.

val shortest_qualid_of_modtype : ?loc:Loc.t -> Names.ModPath.t -> Libnames.qualid
val shortest_qualid_of_module : ?loc:Loc.t -> Names.ModPath.t -> Libnames.qualid
val shortest_qualid_of_dir : ?loc:Loc.t -> GlobDirRef.t -> Libnames.qualid
val shortest_qualid_of_universe : ?loc:Loc.t -> 'u Names.Id.Map.t -> Univ.UGlobal.t -> Libnames.qualid

In general we have a UnivNames.universe_binders around rather than a Id.Set.t