Module RelPath.Chunk

A relational chunk is a short path describing "mandatory" nestings between items: e.g. a field below a struct, an enum below an enum variants, etc.

The types defined by this module are indexed by two other types: 'name and 'disambiguator. This helps for instrumenting the view to perform additional operations: see collect_either, collect and root.

type 'name type_definition = [
  1. | `Enum of 'name
  2. | `Struct of 'name
  3. | `Union of 'name
]

A type can be an enum, a struct or a union. A type is standalone: it has no mandatory parent item.

and 'name constructor = [
  1. | `Constructor of 'name * 'name type_definition
]

A constructor always has a parent type definition.

and 'name maybe_associated = [
  1. | `Fn of 'name
  2. | `Const of 'name
]

Helper type for function and constants: those exist both as associated in an impl block or a trait, and as standalone.

val pp_type_definition : 'name. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> Ppx_deriving_runtime.Format.formatter -> 'name type_definition -> Ppx_deriving_runtime.unit
val show_type_definition : 'name. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> 'name type_definition -> Ppx_deriving_runtime.string
val pp_constructor : 'name. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> Ppx_deriving_runtime.Format.formatter -> 'name constructor -> Ppx_deriving_runtime.unit
val show_constructor : 'name. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> 'name constructor -> Ppx_deriving_runtime.string
val pp_maybe_associated : 'name. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> Ppx_deriving_runtime.Format.formatter -> 'name maybe_associated -> Ppx_deriving_runtime.unit
val show_maybe_associated : 'name. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> 'name maybe_associated -> Ppx_deriving_runtime.string
val compare_type_definition : 'name. ('name -> 'name -> Prelude.int) -> 'name type_definition -> 'name type_definition -> Prelude.int
val compare_constructor : 'name. ('name -> 'name -> Prelude.int) -> 'name constructor -> 'name constructor -> Prelude.int
val compare_maybe_associated : 'name. ('name -> 'name -> Prelude.int) -> 'name maybe_associated -> 'name maybe_associated -> Prelude.int
val __type_definition_of_sexp__ : 'name. (Sexplib0.Sexp.t -> 'name) -> Sexplib0.Sexp.t -> 'name type_definition
val type_definition_of_sexp : 'name. (Sexplib0.Sexp.t -> 'name) -> Sexplib0.Sexp.t -> 'name type_definition
val __constructor_of_sexp__ : 'name. (Sexplib0.Sexp.t -> 'name) -> Sexplib0.Sexp.t -> 'name constructor
val constructor_of_sexp : 'name. (Sexplib0.Sexp.t -> 'name) -> Sexplib0.Sexp.t -> 'name constructor
val __maybe_associated_of_sexp__ : 'name. (Sexplib0.Sexp.t -> 'name) -> Sexplib0.Sexp.t -> 'name maybe_associated
val maybe_associated_of_sexp : 'name. (Sexplib0.Sexp.t -> 'name) -> Sexplib0.Sexp.t -> 'name maybe_associated
val sexp_of_type_definition : 'name. ('name -> Sexplib0.Sexp.t) -> 'name type_definition -> Sexplib0.Sexp.t
val sexp_of_constructor : 'name. ('name -> Sexplib0.Sexp.t) -> 'name constructor -> Sexplib0.Sexp.t
val sexp_of_maybe_associated : 'name. ('name -> Sexplib0.Sexp.t) -> 'name maybe_associated -> Sexplib0.Sexp.t
val hash_fold_type_definition : 'name. (Ppx_hash_lib.Std.Hash.state -> 'name -> Ppx_hash_lib.Std.Hash.state) -> Ppx_hash_lib.Std.Hash.state -> 'name type_definition -> Ppx_hash_lib.Std.Hash.state
val hash_fold_constructor : 'name. (Ppx_hash_lib.Std.Hash.state -> 'name -> Ppx_hash_lib.Std.Hash.state) -> Ppx_hash_lib.Std.Hash.state -> 'name constructor -> Ppx_hash_lib.Std.Hash.state
val hash_fold_maybe_associated : 'name. (Ppx_hash_lib.Std.Hash.state -> 'name -> Ppx_hash_lib.Std.Hash.state) -> Ppx_hash_lib.Std.Hash.state -> 'name maybe_associated -> Ppx_hash_lib.Std.Hash.state
val equal_type_definition : 'name. ('name -> 'name -> Ppx_deriving_runtime.bool) -> 'name type_definition -> 'name type_definition -> Ppx_deriving_runtime.bool
val equal_constructor : 'name. ('name -> 'name -> Ppx_deriving_runtime.bool) -> 'name constructor -> 'name constructor -> Ppx_deriving_runtime.bool
val equal_maybe_associated : 'name. ('name -> 'name -> Ppx_deriving_runtime.bool) -> 'name maybe_associated -> 'name maybe_associated -> Ppx_deriving_runtime.bool
val map_type_definition : ('a -> 'b) -> [< `Enum of 'a | `Struct of 'a | `Union of 'a ] -> [> `Enum of 'b | `Struct of 'b | `Union of 'b ]
val map_constructor : ('a -> 'b) -> [< `Constructor of 'a * [< `Enum of 'a | `Struct of 'a | `Union of 'a ] ] -> [> `Constructor of 'b * [> `Enum of 'b | `Struct of 'b | `Union of 'b ] ]
val map_maybe_associated : ('a -> 'b) -> [< `Const of 'a | `Fn of 'a ] -> [> `Const of 'b | `Fn of 'b ]
type 'name associated = [
  1. | 'name maybe_associated
  2. | `Type of 'name
]

An associated item. This is pulled out of `AssociatedItem below: otherwise, some PPX is broken...

and ('name, 'disambiguator) assoc_parent = [
  1. | `Impl of 'disambiguator * [ `Inherent | `Trait ] * Types.impl_infos Prelude.option
  2. | `Trait of 'name * [ `Alias ] Prelude.option
]

The parent of an associated item can be an impl or a trait.

val pp_associated : 'name. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> Ppx_deriving_runtime.Format.formatter -> 'name associated -> Ppx_deriving_runtime.unit
val show_associated : 'name. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> 'name associated -> Ppx_deriving_runtime.string
val pp_assoc_parent : 'name 'disambiguator. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> (Ppx_deriving_runtime.Format.formatter -> 'disambiguator -> Ppx_deriving_runtime.unit) -> Ppx_deriving_runtime.Format.formatter -> ('name, 'disambiguator) assoc_parent -> Ppx_deriving_runtime.unit
val show_assoc_parent : 'name 'disambiguator. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> (Ppx_deriving_runtime.Format.formatter -> 'disambiguator -> Ppx_deriving_runtime.unit) -> ('name, 'disambiguator) assoc_parent -> Ppx_deriving_runtime.string
val compare_associated : 'name. ('name -> 'name -> Prelude.int) -> 'name associated -> 'name associated -> Prelude.int
val compare_assoc_parent : 'name 'disambiguator. ('name -> 'name -> Prelude.int) -> ('disambiguator -> 'disambiguator -> Prelude.int) -> ('name, 'disambiguator) assoc_parent -> ('name, 'disambiguator) assoc_parent -> Prelude.int
val __associated_of_sexp__ : 'name. (Sexplib0.Sexp.t -> 'name) -> Sexplib0.Sexp.t -> 'name associated
val associated_of_sexp : 'name. (Sexplib0.Sexp.t -> 'name) -> Sexplib0.Sexp.t -> 'name associated
val __assoc_parent_of_sexp__ : 'name 'disambiguator. (Sexplib0.Sexp.t -> 'name) -> (Sexplib0.Sexp.t -> 'disambiguator) -> Sexplib0.Sexp.t -> ('name, 'disambiguator) assoc_parent
val assoc_parent_of_sexp : 'name 'disambiguator. (Sexplib0.Sexp.t -> 'name) -> (Sexplib0.Sexp.t -> 'disambiguator) -> Sexplib0.Sexp.t -> ('name, 'disambiguator) assoc_parent
val sexp_of_associated : 'name. ('name -> Sexplib0.Sexp.t) -> 'name associated -> Sexplib0.Sexp.t
val sexp_of_assoc_parent : 'name 'disambiguator. ('name -> Sexplib0.Sexp.t) -> ('disambiguator -> Sexplib0.Sexp.t) -> ('name, 'disambiguator) assoc_parent -> Sexplib0.Sexp.t
val hash_fold_associated : 'name. (Ppx_hash_lib.Std.Hash.state -> 'name -> Ppx_hash_lib.Std.Hash.state) -> Ppx_hash_lib.Std.Hash.state -> 'name associated -> Ppx_hash_lib.Std.Hash.state
val hash_fold_assoc_parent : 'name 'disambiguator. (Ppx_hash_lib.Std.Hash.state -> 'name -> Ppx_hash_lib.Std.Hash.state) -> (Ppx_hash_lib.Std.Hash.state -> 'disambiguator -> Ppx_hash_lib.Std.Hash.state) -> Ppx_hash_lib.Std.Hash.state -> ('name, 'disambiguator) assoc_parent -> Ppx_hash_lib.Std.Hash.state
val equal_associated : 'name. ('name -> 'name -> Ppx_deriving_runtime.bool) -> 'name associated -> 'name associated -> Ppx_deriving_runtime.bool
val equal_assoc_parent : 'name 'disambiguator. ('name -> 'name -> Ppx_deriving_runtime.bool) -> ('disambiguator -> 'disambiguator -> Ppx_deriving_runtime.bool) -> ('name, 'disambiguator) assoc_parent -> ('name, 'disambiguator) assoc_parent -> Ppx_deriving_runtime.bool
val map_associated : ('a -> 'name) -> [< `Const of 'a | `Fn of 'a | `Type of 'a ] -> 'name associated
val map_assoc_parent : ('a -> 'b) -> ('c -> 'd) -> [< `Impl of 'c * 'e * 'f | `Trait of 'a * 'g ] -> [> `Impl of 'd * 'e * 'f | `Trait of 'b * 'g ]
type ('name, 'disambiguator) poly = [
  1. | 'name type_definition
  2. | 'name constructor
  3. | 'name maybe_associated
  4. | ('name, 'disambiguator) assoc_parent
  5. | `Use of 'disambiguator
  6. | `AnonConst of 'disambiguator
  7. | `InlineConst of 'disambiguator
    (*

    This is e.g.:

    const {
        fn f() {}
    }

    Here, `f` is under an `InlineConst`.

    *)
  8. | `TraitAlias of 'name
  9. | `Foreign of 'disambiguator
  10. | `ForeignTy of 'name
  11. | `TyAlias of 'name
  12. | `ExternCrate of 'name
  13. | `Opaque of 'disambiguator
    (*

    This is e.g.:

    fn f() -> impl Clone {}
    fn g() {
      f();
    }

    Here, the type of `f()` is `<f::OpaqueTy>`.

    *)
  14. | `Static of 'name
  15. | `Macro of 'name
  16. | `AssociatedItem of 'name associated * ('name, 'disambiguator) assoc_parent
  17. | `Mod of 'name
  18. | `GlobalAsm of 'disambiguator
  19. | `Field of 'name * 'name constructor
  20. | `Closure of 'disambiguator
    (*

    We usually never refer to closure: in THIR, we inline closures. However, items can be placed under closures, thus it is present here. See #1450 for more details.

    *)
]

poly is the (polymorphic) type for a relational chunk: it defines what is a chunk.

val pp_poly : 'name 'disambiguator. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> (Ppx_deriving_runtime.Format.formatter -> 'disambiguator -> Ppx_deriving_runtime.unit) -> Ppx_deriving_runtime.Format.formatter -> ('name, 'disambiguator) poly -> Ppx_deriving_runtime.unit
val show_poly : 'name 'disambiguator. (Ppx_deriving_runtime.Format.formatter -> 'name -> Ppx_deriving_runtime.unit) -> (Ppx_deriving_runtime.Format.formatter -> 'disambiguator -> Ppx_deriving_runtime.unit) -> ('name, 'disambiguator) poly -> Ppx_deriving_runtime.string
val compare_poly : 'name 'disambiguator. ('name -> 'name -> Prelude.int) -> ('disambiguator -> 'disambiguator -> Prelude.int) -> ('name, 'disambiguator) poly -> ('name, 'disambiguator) poly -> Prelude.int
val __poly_of_sexp__ : 'name 'disambiguator. (Sexplib0.Sexp.t -> 'name) -> (Sexplib0.Sexp.t -> 'disambiguator) -> Sexplib0.Sexp.t -> ('name, 'disambiguator) poly
val poly_of_sexp : 'name 'disambiguator. (Sexplib0.Sexp.t -> 'name) -> (Sexplib0.Sexp.t -> 'disambiguator) -> Sexplib0.Sexp.t -> ('name, 'disambiguator) poly
val sexp_of_poly : 'name 'disambiguator. ('name -> Sexplib0.Sexp.t) -> ('disambiguator -> Sexplib0.Sexp.t) -> ('name, 'disambiguator) poly -> Sexplib0.Sexp.t
val hash_fold_poly : 'name 'disambiguator. (Ppx_hash_lib.Std.Hash.state -> 'name -> Ppx_hash_lib.Std.Hash.state) -> (Ppx_hash_lib.Std.Hash.state -> 'disambiguator -> Ppx_hash_lib.Std.Hash.state) -> Ppx_hash_lib.Std.Hash.state -> ('name, 'disambiguator) poly -> Ppx_hash_lib.Std.Hash.state
val equal_poly : 'name 'disambiguator. ('name -> 'name -> Ppx_deriving_runtime.bool) -> ('disambiguator -> 'disambiguator -> Ppx_deriving_runtime.bool) -> ('name, 'disambiguator) poly -> ('name, 'disambiguator) poly -> Ppx_deriving_runtime.bool
val map_poly : ('a -> 'name) -> ('b -> 'disambiguator) -> [< `AnonConst of 'b | `AssociatedItem of [< `Const of 'a | `Fn of 'a | `Type of 'a ] * [< `Impl of 'b * [ `Inherent | `Trait ] * Types.impl_infos Prelude.option | `Trait of 'a * [ `Alias ] Prelude.option ] | `Closure of 'b | `Const of 'a | `Constructor of 'a * 'a type_definition | `Enum of 'a | `ExternCrate of 'a | `Field of 'a * [< `Constructor of 'a * [< `Enum of 'a | `Struct of 'a | `Union of 'a ] ] | `Fn of 'a | `Foreign of 'b | `ForeignTy of 'a | `GlobalAsm of 'b | `Impl of 'b * [ `Inherent | `Trait ] * Types.impl_infos Prelude.option | `InlineConst of 'b | `Macro of 'a | `Mod of 'a | `Opaque of 'b | `Static of 'a | `Struct of 'a | `Trait of 'a * [ `Alias ] Prelude.option | `TraitAlias of 'a | `TyAlias of 'a | `Union of 'a | `Use of 'b ] -> ('name, 'disambiguator) poly

t is the natural instantiation of poly.

val pp : Ppx_deriving_runtime.Format.formatter -> t -> Ppx_deriving_runtime.unit
val show : t -> Ppx_deriving_runtime.string
val compare : t -> t -> Prelude.int
val t_of_sexp : Sexplib0.Sexp.t -> t
val sexp_of_t : t -> Sexplib0.Sexp.t
val hash_fold_t : Ppx_hash_lib.Std.Hash.state -> t -> Ppx_hash_lib.Std.Hash.state
val hash : t -> Ppx_hash_lib.Std.Hash.hash_value
val equal : t -> t -> Ppx_deriving_runtime.bool
val add_strings : ?impl:Prelude.string -> ?anon_const:Prelude.string -> ?foreign:Prelude.string -> ?global_asm:Prelude.string -> t -> (DisambiguatedString.t, DisambiguatedString.t) poly

Transforms a t into a poly with annotated strings instead of just disambiguators. This adds names to the disambiguator-only constructs defined in poly.

val only_disambiguators : t -> (disambiguator, disambiguator) poly

Erases names from a t.

val collect_either : 'n 'd. ('n, 'd) poly -> [ `D of 'd | `N of 'n ] Prelude.list

Collects all the data of a t, from the child to the parent.

val collect : 'a. ('a, 'a) poly -> 'a Prelude.list

Same as collect_either, but works on a poly whose 'name and 'disambiguator happen to be the same type.

val root : 'a. ('a, 'a) poly -> 'a

Find the root of a poly.