package merlin-lib

  1. Overview
  2. Docs
Merlin's libraries

Install

Dune Dependency

Authors

Maintainers

Sources

merlin-5.5-503.tbz
sha256=67da3b34f2fea07678267309f61da4a2c6f08298de0dc59655b8d30fd8269af1
sha512=1fb3b5180d36aa82b82a319e15b743b802b6888f0dc67645baafdb4e18dfc23a7b90064ec9bc42f7424061cf8cde7f8839178d8a8537bf4596759f3ff4891873

doc/merlin-lib.ocaml_typing/Ocaml_typing/Shape/index.html

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:

  • Build the Shape corresponding to the value's path: let shape = Env.shape_of_path ~namespace env path
  • Instantiate the Shape_reduce.Make functor with a way to load shapes from external units and to looks for shapes in the environment (usually using Env.shape_of_path).
  • Completely reduce the shape: let shape = My_reduce.(weak_)reduce env shape
  • The Uid.t stored in the reduced shape should be the one of the definition. However, if the approximate field of the reduced shape is true then the Uid.t will not correspond to the definition, but to the closest parent module's uid. This happens when Shape reduction gets stuck, for example when hitting first-class modules.
  • The location of the definition can be easily found with the cmt_format.cmt_uid_to_decl table of the corresponding compilation unit.

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
OCaml

Innovation. Community. Security.