Module Odoc_xref2.Tools

Lookup and resolve functions

lookup_module ~mark_substituted env p takes a resolved module cpath p and an environment and returns a representation of the module.

lookup_module_type ~mark_substituted env p takes a resolved module type cpath and an environment and returns a representation of the module type.

lookup_type env p takes a resolved type path and an environment and returns a representation of the type. The type can be an ordinary type, a class type or a class. If the type has been destructively substituted, the path to the replacement type will be returned instead.

lookup_class_type env p takes a resolved class type path and an environment and returns a representation of the class type. The type can be a class type or a class.

resolve_module ~mark_substituted ~add_canonical env p takes an unresolved module path and an environment and returns a tuple of the resolved module path alongside a representation of the module itself.

resolve_module_type ~mark_substituted env p takes an unresolved module type path and an environment and returns a tuple of the resolved module type path alongside a representation of the module type itself.

resolve_type env p takes an unresolved type path and an environment and returns a tuple of the resolved type path alongside a representation of the type itself. As with lookup_type the returned type is either the type, class or class type, or if has been destructively substituted the return value is the path to the replaced type, class or class type.

resolve_class_type env p takes an unresolved class type path and an environment and returns a tuple of the resolved class type path alongside a representation of the class type itself. As with lookup_type the returned type is either the class or class type.

Convenience functions

val resolve_module_path : Env.t -> Cpath.module_ -> (Cpath.Resolved.module_Errors.Tools_error.simple_module_lookup_error) Result.result
val resolve_module_type_path : Env.t -> Cpath.module_type -> (Cpath.Resolved.module_typeErrors.Tools_error.simple_module_type_lookup_error) Result.result
val resolve_type_path : Env.t -> Cpath.type_ -> (Cpath.Resolved.type_Errors.Tools_error.simple_type_lookup_error) Result.result
val resolve_class_type_path : Env.t -> Cpath.class_type -> (Cpath.Resolved.class_typeErrors.Tools_error.simple_type_lookup_error) Result.result

Re-resolve functions

val reresolve_module : Env.t -> Cpath.Resolved.module_ -> Cpath.Resolved.module_
val reresolve_module_type : Env.t -> Cpath.Resolved.module_type -> Cpath.Resolved.module_type
val reresolve_type : Env.t -> Cpath.Resolved.type_ -> Cpath.Resolved.type_

Ref_tools helpers

val reresolve_parent : Env.t -> Cpath.Resolved.parent -> Cpath.Resolved.parent
val handle_module_type_lookup : Env.t -> string -> Cpath.Resolved.parent -> Component.Signature.t -> Component.Substitution.t -> (Cpath.Resolved.module_type * Component.ModuleType.t) option
type module_modifiers = [
| `Aliased of Cpath.Resolved.module_
| `SubstAliased of Cpath.Resolved.module_
| `SubstMT of Cpath.Resolved.module_type
]
val get_module_path_modifiers : Env.t -> add_canonical:bool -> Component.Module.t -> module_modifiers option
val prefix_signature : (Cpath.Resolved.parent * Component.Signature.t) -> Component.Signature.t
val signature_of_module : Env.t -> Component.Module.t -> (Component.Signature.tErrors.Tools_error.signature_of_module_error) Result.result
val signature_of_module_type : Env.t -> Component.ModuleType.t -> (Component.Signature.tErrors.Tools_error.signature_of_module_error) Result.result
val class_signature_of_class_type : Env.t -> Component.ClassType.t -> Component.ClassSignature.t option
val class_signature_of_class : Env.t -> Component.Class.t -> Component.ClassSignature.t option

Fragment resolution

val signature_of_module_type_expr : mark_substituted:bool -> Env.t -> Component.ModuleType.expr -> (Component.Signature.tErrors.Tools_error.signature_of_module_error) Result.result

The following functions are use for the resolution of Fragments Whilst resolving fragments it is necessary to process them in order, applying the 'with' expression of module or type equality or substitution, before resolving the next fragment. The function signature_of_module_type_expr is used to supply the signature for the first fragment. For this purpose, mark_substituted should be true. As for the path resolution functions above, the resolve functions may be called during compile or link, whereas the reresolve functions should only be called during the link phase.

val signature_of_u_module_type_expr : mark_substituted:bool -> Env.t -> Component.ModuleType.U.expr -> (Component.Signature.tErrors.Tools_error.signature_of_module_error) Result.result

The following functions are use for the resolution of Fragments Whilst resolving fragments it is necessary to process them in order, applying the 'with' expression of module or type equality or substitution, before resolving the next fragment. The function signature_of_module_type_expr is used to supply the signature for the first fragment. For this purpose, mark_substituted should be true. As for the path resolution functions above, the resolve functions may be called during compile or link, whereas the reresolve functions should only be called during the link phase.

val resolve_module_fragment : Env.t -> (Cfrag.root * Component.Signature.t) -> Cfrag.module_ -> Cfrag.resolved_module option
val resolve_type_fragment : Env.t -> (Cfrag.root * Component.Signature.t) -> Cfrag.type_ -> Cfrag.resolved_type option
val reresolve_module_fragment : Env.t -> Cfrag.resolved_module -> Cfrag.resolved_module
val reresolve_type_fragment : Env.t -> Cfrag.resolved_type -> Cfrag.resolved_type

Fragmap functions

fragmap ~mark_substituted env sub sg takes an environment env and signature sg, and a fragment substitution (e.g. ModuleSubst to destructively substitute a module), and returns the substituted signature.

handle_signature_with_subs ~mark_substituted env sg subs applies the fragment modifiers subs, in order, to the supplied signature sg.

Cache handling

val reset_caches : unit -> unit

Empty the caches completely

val disable_all_caches : unit -> unit

Disable the caches completely