1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(*i $Id: libnames.mli 11576 2008-11-10 19:13:15Z msozeau $ i*)
19
(*s Global reference is a kernel side type for all references together *)
20
type global_reference =
22
| ConstRef of constant
24
| ConstructRef of constructor
26
val isVarRef : global_reference -> bool
28
val subst_constructor : substitution -> constructor -> constructor * constr
29
val subst_global : substitution -> global_reference -> global_reference * constr
31
(* Turn a global reference into a construction *)
32
val constr_of_global : global_reference -> constr
34
(* Turn a construction denoting a global reference into a global reference;
35
raise [Not_found] if not a global reference *)
36
val global_of_constr : constr -> global_reference
38
(* Obsolete synonyms for constr_of_global and global_of_constr *)
39
val constr_of_reference : global_reference -> constr
40
val reference_of_constr : constr -> global_reference
42
module Refset : Set.S with type elt = global_reference
43
module Refmap : Map.S with type key = global_reference
46
val pr_dirpath : dir_path -> Pp.std_ppcmds
48
val dirpath_of_string : string -> dir_path
50
(* Give the immediate prefix of a [dir_path] *)
51
val dirpath_prefix : dir_path -> dir_path
53
(* Give the immediate prefix and basename of a [dir_path] *)
54
val split_dirpath : dir_path -> dir_path * identifier
56
val extend_dirpath : dir_path -> module_ident -> dir_path
57
val add_dirpath_prefix : module_ident -> dir_path -> dir_path
59
val chop_dirpath : int -> dir_path -> dir_path * dir_path
60
val drop_dirpath_prefix : dir_path -> dir_path -> dir_path
61
val extract_dirpath_prefix : int -> dir_path -> dir_path
62
val is_dirpath_prefix_of : dir_path -> dir_path -> bool
63
val append_dirpath : dir_path -> dir_path -> dir_path
65
module Dirset : Set.S with type elt = dir_path
66
module Dirmap : Map.S with type key = dir_path
68
(*s Section paths are {\em absolute} names *)
71
(* Constructors of [section_path] *)
72
val make_path : dir_path -> identifier -> section_path
74
(* Destructors of [section_path] *)
75
val repr_path : section_path -> dir_path * identifier
76
val dirpath : section_path -> dir_path
77
val basename : section_path -> identifier
79
(* Parsing and printing of section path as ["coq_root.module.id"] *)
80
val path_of_string : string -> section_path
81
val string_of_path : section_path -> string
82
val pr_sp : section_path -> std_ppcmds
84
module Sppred : Predicate.S with type elt = section_path
85
module Spmap : Map.S with type key = section_path
87
val restrict_path : int -> section_path -> section_path
89
type extended_global_reference =
90
| TrueGlobal of global_reference
91
| SyntacticDef of kernel_name
93
(*s Temporary function to brutally form kernel names from section paths *)
95
val encode_kn : dir_path -> identifier -> kernel_name
96
val decode_kn : kernel_name -> dir_path * identifier
97
val encode_con : dir_path -> identifier -> constant
98
val decode_con : constant -> dir_path * identifier
101
(*s A [qualid] is a partially qualified ident; it includes fully
102
qualified names (= absolute names) and all intermediate partial
103
qualifications of absolute names, including single identifiers *)
106
val make_qualid : dir_path -> identifier -> qualid
107
val repr_qualid : qualid -> dir_path * identifier
109
val string_of_qualid : qualid -> string
110
val pr_qualid : qualid -> std_ppcmds
112
val qualid_of_string : string -> qualid
114
(* Turns an absolute name into a qualified name denoting the same name *)
115
val qualid_of_sp : section_path -> qualid
117
val qualid_of_dirpath : dir_path -> qualid
119
val make_short_qualid : identifier -> qualid
121
(* Both names are passed to objects: a "semantic" [kernel_name], which
122
can be substituted and a "syntactic" [section_path] which can be printed
125
type object_name = section_path * kernel_name
127
type object_prefix = dir_path * (module_path * dir_path)
129
val make_oname : object_prefix -> identifier -> object_name
131
(* to this type are mapped [dir_path]'s in the nametab *)
132
type global_dir_reference =
133
| DirOpenModule of object_prefix
134
| DirOpenModtype of object_prefix
135
| DirOpenSection of object_prefix
136
| DirModule of object_prefix
137
| DirClosedSection of dir_path
138
(* this won't last long I hope! *)
141
| Qualid of qualid located
142
| Ident of identifier located
144
val qualid_of_reference : reference -> qualid located
145
val string_of_reference : reference -> string
146
val pr_reference : reference -> std_ppcmds
147
val loc_of_reference : reference -> loc
149
(* popping one level of section in global names *)
151
val pop_con : constant -> constant
152
val pop_kn : kernel_name -> kernel_name
153
val pop_global_reference : global_reference -> global_reference