Module Ocaml_typing.ShapeSource

Shapes are an abstract representation of modules' implementations which allow the tracking of definitions through functor applications and other module-level operations.

The Shape of a compilation unit is elaborated during typing, partially reduced (without loading external shapes) and written to the cmt file.

External tools can retrieve the definition of any value (or type, or module, etc) by following this procedure:

See:

Sourcemodule Uid : sig ... end

A Uid.t is associated to every declaration in signatures and implementations. They uniquely identify bindings in the program. When associated with these bindings' locations they are useful to external tools when trying to jump to an identifier's declaration or definition. They are stored to that effect in the uid_to_decl table of cmt files.

Sourcemodule Sig_component_kind : sig ... end
Sourcemodule Item : sig ... end

Shape's items are elements of a structure or, in the case of constructors and labels, elements of a record or variants definition seen as a structure. These structures model module components and nested types' constructors and labels.

Sourcetype var = Ident.t
Sourcetype t = {
  1. uid : Uid.t option;
  2. desc : desc;
  3. approximated : bool;
}
Sourceand desc =
  1. | Var of var
  2. | Abs of var * t
  3. | App of t * t
  4. | Struct of t Item.Map.t
  5. | Alias of t
  6. | Leaf
  7. | Proj of t * Item.t
  8. | Comp_unit of string
  9. | Error of string
Sourceval print : Format.formatter -> t -> unit
Sourceval strip_head_aliases : t -> t
Sourceval for_unnamed_functor_param : var
Sourceval fresh_var : ?name:string -> Uid.t -> var * t
Sourceval var : Uid.t -> Ident.t -> t
Sourceval abs : ?uid:Uid.t -> var -> t -> t
Sourceval app : ?uid:Uid.t -> t -> arg:t -> t
Sourceval str : ?uid:Uid.t -> t Item.Map.t -> t
Sourceval alias : ?uid:Uid.t -> t -> t
Sourceval proj : ?uid:Uid.t -> t -> Item.t -> t
Sourceval leaf : Uid.t -> t
Sourceval decompose_abs : t -> (var * t) option
Sourceval for_persistent_unit : string -> t
Sourceval leaf_for_unpack : t
Sourcemodule Map : sig ... end
Sourceval dummy_mod : t
Sourceval of_path : find_shape:(Sig_component_kind.t -> Ident.t -> t) -> namespace:Sig_component_kind.t -> Path.t -> t
Sourceval set_uid_if_none : t -> Uid.t -> t