Module Ocaml_typing.Types

Representation of types and declarations

Types defines the representation of types and declarations (that is, the content of module signatures).

CMI files are made of marshalled types.

Asttypes exposes basic definitions shared both by Parsetree and Types.

type atomic =
  1. | Nonatomic
  2. | Atomic

Whether or not a mutable field is atomic

type mutability =
  1. | Immutable
  2. | Mutable of {
    1. mode : Mode.Value.Comonadic.lr;
      (*

      Mode of new field value in mutation.

      *)
    2. atomic : atomic;
    }

Describes a mutable field/element.

val is_mutable : mutability -> bool

Returns true is the mutable_flag is mutable or atomic. Should be called if not interested in the payload of Mutable.

val is_atomic : mutability -> bool

Returns true is the mutable_flag is atomic. Should be called if not interested in the payload of Mutable.

val mutable_mode : ('l * 'r) Mode.Value.Comonadic.t -> ('l * 'r) Mode.Value.t

Given the parameter m0 on mutable, return the mode of future writes.

Type expressions for the core language.

The type_desc variant defines all the possible type expressions one can find in OCaml. type_expr wraps this with some annotations.

The level field tracks the level of polymorphism associated to a type, guiding the generalization algorithm. Put shortly, when referring to a type in a given environment, both the type and the environment have a level. If the type has an higher level, then it can be considered fully polymorphic (type variables will be printed as 'a), otherwise it'll be weakly polymorphic, or non generalized (type variables printed as '_a). See http://okmij.org/ftp/ML/generalization.html for more information.

Note about type_declaration: one should not make the confusion between type_expr and type_declaration.

type_declaration refers specifically to the type construct in OCaml language, where you create and name a new type or type alias.

type_expr is used when you refer to existing types, e.g. when annotating the expected type of a value.

Also, as the type system of OCaml is generative, a type_declaration can have the side-effect of introducing a new type constructor, different from all other known types. Whereas type_expr is a pure construct which allows referring to existing types.

Note on mutability: TBD.

module Jkind_mod_bounds : sig ... end

The mod-bounds of a jkind

module With_bounds_type_info : sig ... end

Information tracked about an individual type within the with-bounds for a jkind

type type_expr
type row_desc
type row_field
type field_kind
type commutable
and type_desc =
  1. | Tvar of {
    1. name : string option;
    2. jkind : jkind_lr;
    }
    (*

    Tvar (Some "a") ==> 'a or '_a Tvar None ==> _

    *)
  2. | Tarrow of arrow_desc * type_expr * type_expr * commutable
    (*

    Tarrow (Nolabel, e1, e2, c) ==> e1 -> e2 Tarrow (Labelled "l", e1, e2, c) ==> l:e1 -> e2 Tarrow (Optional "l", e1, e2, c) ==> ?l:e1 -> e2

    See commutable for the last argument. The argument type must be a Tpoly node

    *)
  3. | Ttuple of (string option * type_expr) list
    (*

    Ttuple [None, t1; ...; None, tn] ==> t1 * ... * tn Ttuple [Some "l1", t1; ...; Some "ln", tn] ==> l1:t1 * ... * ln:tn

    Any mix of labeled and unlabeled components also works: Ttuple [Some "l1", t1; None, t2; Some "l3", t3] ==> l1:t1 * t2 * l3:t3

    *)
  4. | Tunboxed_tuple of (string option * type_expr) list
    (*

    Tunboxed_tuple [None, t1; ...; None, tn] ==> #(t1 * ... * tn) Tunboxed_tuple [Some "l1", t1; ...; Some "ln", tn] ==> #(l1:t1 * ... * ln:tn)

    Any mix of labeled and unlabeled components also works: Tunboxed_tuple [Some "l1", t1; None, t2; Some "l3", t3] ==> #(l1:t1 * t2 * l3:t3)

    *)
  5. | Tconstr of Path.t * type_expr list * abbrev_memo ref
    (*

    Tconstr (`A.B.t', [t1;...;tn], _) ==> (t1,...,tn) A.B.t The last parameter keep tracks of known expansions, see abbrev_memo.

    *)
  6. | Tobject of type_expr * (Path.t * type_expr list) option ref
    (*

    Tobject (`f1:t1;...;fn: tn', `None') ==> < f1: t1; ...; fn: tn > f1, fn are represented as a linked list of types using Tfield and Tnil constructors.

    Tobject (_, `Some (`A.ct', [t1;...;tn]') ==> (t1, ..., tn) A.ct. where A.ct is the type of some class.

    There are also special cases for so-called "class-types", cf. Typeclass and Ctype.set_object_name:

    Tobject (Tfield(_,_,...(Tfield(_,_,rv)...), Some(`A.#ct`, [rv;t1;...;tn]) ==> (t1, ..., tn) #A.ct Tobject (_, Some(`A.#ct`, [Tnil;t1;...;tn]) ==> (t1, ..., tn) A.ct

    where rv is the hidden row variable.

    *)
  7. | Tfield of string * field_kind * type_expr * type_expr
    (*

    Tfield ("foo", field_public, t, ts) ==> <...; foo : t; ts>

    *)
  8. | Tquote of type_expr
    (*

    Tquote t ==> <[ t ]>

    *)
  9. | Tsplice of type_expr
    (*

    Tsplice t ==> $t

    *)
  10. | Tnil
    (*

    Tnil ==> <...; >

    *)
  11. | Tsubst of type_expr * type_expr option
    (*

    Tsubst is used temporarily to store information in low-level functions manipulating representation of types, such as instantiation or copy. The first argument contains a copy of the original node. The second is available only when the first is the row variable of a polymorphic variant. It then contains a copy of the whole variant. This constructor should not appear outside of these cases.

    *)
  12. | Tvariant of row_desc
    (*

    Representation of polymorphic variants, see row_desc.

    *)
  13. | Tunivar of {
    1. name : string option;
    2. jkind : jkind_lr;
    }
    (*

    Occurrence of a type variable introduced by a forall quantifier / Tpoly.

    *)
  14. | Tpoly of type_expr * type_expr list
    (*

    Tpoly (ty,tyl) ==> 'a1... 'an. ty, where 'a1 ... 'an are names given to types in tyl and occurrences of those types in ty.

    *)
  15. | Tpackage of Path.t * (Ocaml_parsing.Longident.t * type_expr) list
    (*

    Type of a first-class module (a.k.a package).

    *)
  16. | Tof_kind of jkind_lr
    (*

    Tof_kind jkind ==> (type : jkind)

    The "canonical" type of a particular kind.

    These types are uninhabited, and any appearing in translation will cause an error. They are only used to represent the kinds of existentially-quantified types mentioned in with-bounds. See test typing-jkind-bounds/gadt.ml

    *)
and arg_label =
  1. | Nolabel
  2. | Labelled of string
    (*

    label:T -> ...

    *)
  3. | Optional of string
    (*

    ?label:T -> ...

    *)
  4. | Position of string
    (*

    label:[%call_pos] -> ...

    *)

This is used in the Typedtree. It is distinct from arg_label because Position argument labels are discovered through typechecking.

and fixed_explanation =
  1. | Univar of type_expr
    (*

    The row type was bound to an univar

    *)
  2. | Fixed_private
    (*

    The row type is private

    *)
  3. | Reified of Path.t
    (*

    The row was reified

    *)
  4. | Rigid
    (*

    The row type was made rigid during constraint verification

    *)
  5. | Fixed_existential
    (*

    The row type is existential in a with-bound. See Note With-bounds for GADTs in Jkind.

    *)

See also documentation for row_more, which enumerates how these constructors arise.

and abbrev_memo =
  1. | Mnil
    (*

    No known abbreviation

    *)
  2. | Mcons of Ocaml_parsing.Asttypes.private_flag * Path.t * type_expr * type_expr * abbrev_memo
    (*

    Found one abbreviation. A valid abbreviation should be at least as visible and reachable by the same path. The first expression is the abbreviation and the second the expansion.

    *)

abbrev_memo allows one to keep track of different expansions of a type alias. This is done for performance purposes.

For instance, when defining type 'a pair = 'a * 'a, when one refers to an 'a pair, it is just a shortcut for the 'a * 'a type. This expansion will be stored in the abbrev_memo of the corresponding Tconstr node.

In practice, abbrev_memo behaves like list of expansions with a mutable tail.

Note on marshalling: abbrev_memo must not appear in saved types. Btype, with cleanup_abbrev and memo, takes care of tracking and removing abbreviations.

commutable is a flag appended to every arrow type.

When typing an application, if the type of the functional is known, its type is instantiated with commu_ok arrows, otherwise as commu_var ().

When the type is not known, the application will be used to infer the actual type. This is fragile in presence of labels where there is no principal type.

Two incompatible applications must rely on is_commu_ok arrows, otherwise they will trigger an error.

let f g = g ~a:() ~b:(); g ~b:() ~a:();

Error: This function is applied to arguments in an order different from other calls. This is only allowed when the real type is known.

and jkind_history =
  1. | Interact of {
    1. reason : Jkind_intf.History.interact_reason;
    2. jkind1 : jkind_desc_packed;
    3. history1 : jkind_history;
    4. jkind2 : jkind_desc_packed;
    5. history2 : jkind_history;
    }
  2. | Creation of Jkind_intf.History.creation_reason

A history of conditions placed on a jkind.

INVARIANT: at most one sort variable appears in this history. This is a natural consequence of producing this history by comparing jkinds.

and with_bounds_types

The types within the with-bounds of a jkind

and 'd with_bounds =
  1. | No_with_bounds : ('l * 'r) with_bounds
  2. | With_bounds : with_bounds_types -> ('l * Allowance.disallowed) with_bounds
    (*

    Invariant : there must always be at least one type in this set *

    *)
and ('layout, 'd) layout_and_axes = {
  1. layout : 'layout;
  2. mod_bounds : Jkind_mod_bounds.t;
  3. with_bounds : 'd with_bounds;
} constraint 'd = 'l * 'r
and 'd jkind_desc = (Jkind_types.Sort.t Jkind_types.Layout.t, 'd) layout_and_axes constraint 'd = 'l * 'r
and jkind_desc_packed =
  1. | Pack_jkind_desc : ('l * 'r) jkind_desc -> jkind_desc_packed
and 'd jkind_quality =
  1. | Best : ('l * Allowance.disallowed) jkind_quality
  2. | Not_best : ('l * 'r) jkind_quality

The "quality" of a jkind indicates whether we are able to learn more about the jkind later.

We can never learn more about a Best jkind to make it "lower" (according to Jkind.sub / Jkind.sub_jkind_l). A Not_best, jkind, however, might have more information provided about it later that makes it lower.

Note that only left jkinds can be Best (meaning we can never compare less than or equal to a left jkind!)

and 'd jkind = {
  1. jkind : 'd jkind_desc;
  2. annotation : Ocaml_parsing.Parsetree.jkind_annotation option;
  3. history : jkind_history;
  4. has_warned : bool;
  5. ran_out_of_fuel_during_normalize : bool;
  6. quality : 'd jkind_quality;
} constraint 'd = 'l * 'r
and jkind_packed =
  1. | Pack_jkind : ('l * 'r) jkind -> jkind_packed
module With_bounds_types : sig ... end
val is_commu_ok : commutable -> bool
val commu_ok : commutable
val commu_var : unit -> commutable

field_kind indicates the accessibility of a method.

An Fprivate field may become Fpublic or Fabsent during unification, but not the other way round.

The same field_kind is kept shared when copying Tfield nodes so that the copies of the self-type of a class share the same accessibility (see also PR#10539).

type field_kind_view =
  1. | Fprivate
  2. | Fpublic
  3. | Fabsent
val field_kind_repr : field_kind -> field_kind_view
val field_public : field_kind
val field_absent : field_kind
val field_private : unit -> field_kind
val field_kind_internal_repr : field_kind -> field_kind

Getters for type_expr; calls repr before answering a value

val get_desc : type_expr -> type_desc
val get_level : type_expr -> int
val get_scope : type_expr -> int
val get_id : type_expr -> int
type type_mark

Access to marks. They are stored in the scope field.

val with_type_mark : (type_mark -> 'a) -> 'a
val not_marked_node : type_mark -> type_expr -> bool
val try_mark_node : type_mark -> type_expr -> bool
type transient_expr = private {
  1. mutable desc : type_desc;
  2. mutable level : int;
  3. mutable scope : scope_field;
  4. id : int;
}

Transient type_expr. Should only be used immediately after Transient_expr.repr

and scope_field
module Transient_expr : sig ... end

Operations on transient_expr

val create_expr : type_desc -> level:int -> scope:int -> id:int -> type_expr

Functions and definitions moved from Btype

val newty3 : level:int -> scope:int -> type_desc -> type_expr

Create a type with a fresh id

val newty2 : level:int -> type_desc -> type_expr

Create a type with a fresh id and no scope

module TransientTypeOps : sig ... end

Comparisons for functors

Comparisons for type_expr; cannot be used for functors

val eq_type : type_expr -> type_expr -> bool
val compare_type : type_expr -> type_expr -> int

Constructor and accessors for row_desc

`X | `Y (row_closed = true) < `X | `Y (row_closed = true) > `X | `Y (row_closed = false) < `X | `Y > `X (row_closed = true)

type t = > `X as 'a (row_more = Tvar a) type t = private > `X (row_more = Tconstr ("t#row", , ref Mnil))

And for:

let f = function `X -> `X -> | `Y -> `X

the type of "f" will be a Tarrow whose lhs will (basically) be:

Tvariant row_fields = [("X", _)]; row_more = Tvariant { row_fields = [("Y", _)]; row_more = Tvariant { row_fields = []; row_more = _; _ ; _

}

; _

}

val create_row : fields:(Ocaml_parsing.Asttypes.label * row_field) list -> more:type_expr -> closed:bool -> fixed:fixed_explanation option -> name:(Path.t * type_expr list) option -> row_desc
val row_fields : row_desc -> (Ocaml_parsing.Asttypes.label * row_field) list
val row_more : row_desc -> type_expr

row_more returns a type_expr with one of the following type_descs (also described with the return from row_fixed, which varies similarly):

* Tvar: This is a row variable; it would occur in e.g. val f : [> `A | `B] -> int. When/if we learn more about a polymorphic variant, this variable might get unified with one of the other type_descs listed here, or a Tvariant that represents a new set of constructors to add to the row.

During constraint checking (toward the end of checking a type declaration, in Typedecl.check_constraints_rec) we Ctype.rigidify a type to make it so that its unification variables will not unify. When a Tvar row variable is rigidified, its fixed_explanation will be Rigid.

* Tunivar: This is a universally quantified row variable; it would occur in e.g. type t = { f : 'a. ([> `A | `B ] as 'a) -> int }. A Tunivar has a fixed_explanation of Univar.

* Tconstr: There are two possible ways this can happen:

1. This is an abstract #row type created by a private row type, as in type t = private [> `A | `B]. In this case, the fixed_explanation will be Fixed_private.

2. This is a locally abstract type created by Ctype.reify, which happens when a row variable is free in the type of the scrutinee in a GADT pattern match. The fixed_explanation will be Reified. Note that any manifest of a reified row variable is actually ignored by row_repr; this causes some incompletness in type inference.

* Tnil: Used to denote a static polymorphic variant (with no > or <).

* Tof_kind: See Wrinkle BW2 in Note With-bounds for GADTs in Jkind. Briefly, Tof_kind can appear as a row_more when computing the kind of a GADT with an existentially-bound row variable. The fixed_explanation will be Fixed_existential.

----------------------------------------

It is an invariant that row variables are never shared between different types. That is, if row_more row1 == row_more row2, then row1 and row2 come from structurally identical Tvariants (but they might not be physically equal). When copying types, two types with the same row_more field are replaced by the same copy.

val row_closed : row_desc -> bool
val row_fixed : row_desc -> fixed_explanation option

See documentation for row_more.

val row_name : row_desc -> (Path.t * type_expr list) option
val set_row_name : row_desc -> (Path.t * type_expr list) option -> row_desc
type row_desc_repr =
  1. | Row of {
    1. fields : (Ocaml_parsing.Asttypes.label * row_field) list;
    2. more : type_expr;
    3. closed : bool;
    4. fixed : fixed_explanation option;
    5. name : (Path.t * type_expr list) option;
    }

get all fields at once; different from the old row_repr

val row_repr : row_desc -> row_desc_repr
type row_field_view =
  1. | Rpresent of type_expr option
  2. | Reither of bool * type_expr list * bool
  3. | Rabsent

Current contents of a row field

val row_field_repr : row_field -> row_field_view
val rf_present : type_expr option -> row_field
val rf_absent : row_field
val rf_either : ?use_ext_of:row_field -> no_arg:bool -> type_expr list -> matched:bool -> row_field
val rf_either_of : type_expr option -> row_field
val eq_row_field_ext : row_field -> row_field -> bool
val changed_row_field_exts : row_field list -> (unit -> unit) -> bool
val match_row_field : present:(type_expr option -> 'a) -> absent:(unit -> 'a) -> either:(bool -> type_expr list -> bool -> row_field option -> 'a) -> row_field -> 'a
module Uid = Shape.Uid
module MethSet : Set.S with type elt = string
module VarSet : Set.S with type elt = string
module Meths : Map.S with type key = string
module Vars : Map.S with type key = string
type value_kind =
  1. | Val_reg of Jkind_types.Sort.t
  2. | Val_mut of Mode.Value.Comonadic.lr * Jkind_types.Sort.t
  3. | Val_prim of Primitive.description
  4. | Val_ivar of Ocaml_parsing.Asttypes.mutable_flag * string
  5. | Val_self of class_signature * self_meths * Ident.t Vars.t * string
  6. | Val_anc of class_signature * Ident.t Meths.t * string
and self_meths =
  1. | Self_concrete of Ident.t Meths.t
  2. | Self_virtual of Ident.t Meths.t ref
and class_signature = {
  1. csig_self : type_expr;
  2. mutable csig_self_row : type_expr;
  3. mutable csig_vars : (Ocaml_parsing.Asttypes.mutable_flag * Ocaml_parsing.Asttypes.virtual_flag * type_expr) Vars.t;
  4. mutable csig_meths : (method_privacy * Ocaml_parsing.Asttypes.virtual_flag * type_expr) Meths.t;
}
and method_privacy =
  1. | Mpublic
  2. | Mprivate of field_kind
module Variance : sig ... end
module Separability : sig ... end

see Typedecl_separability for an explanation of separability and separability modes.

type type_declaration = {
  1. type_params : type_expr list;
  2. type_arity : int;
  3. type_kind : type_decl_kind;
  4. type_jkind : jkind_l;
  5. type_private : Ocaml_parsing.Asttypes.private_flag;
  6. type_manifest : type_expr option;
  7. type_variance : Variance.t list;
  8. type_separability : Separability.t list;
  9. type_is_newtype : bool;
  10. type_expansion_scope : int;
  11. type_loc : Ocaml_parsing.Location.t;
  12. type_attributes : Ocaml_parsing.Parsetree.attributes;
  13. type_unboxed_default : bool;
  14. type_uid : Uid.t;
  15. type_unboxed_version : type_declaration option;
}
and unsafe_mode_crossing = {
  1. unsafe_mod_bounds : Mode.Crossing.t;
  2. unsafe_with_bounds : (Allowance.allowed * Allowance.disallowed) with_bounds;
}
and ('lbl, 'lbl_flat, 'cstr) type_kind =
  1. | Type_abstract of type_origin
  2. | Type_record of 'lbl list * record_representation * unsafe_mode_crossing option
  3. | Type_record_unboxed_product of 'lbl_flat list * record_unboxed_product_representation * unsafe_mode_crossing option
  4. | Type_variant of 'cstr list * variant_representation * unsafe_mode_crossing option
  5. | Type_open
and tag =
  1. | Ordinary of {
    1. src_index : int;
    2. runtime_tag : int;
    }
  2. | Extension of Path.t
  3. | Null
and mixed_block_element =
  1. | Value
  2. | Float_boxed
  3. | Float64
  4. | Float32
  5. | Bits8
  6. | Bits16
  7. | Untagged_immediate
  8. | Bits32
  9. | Bits64
  10. | Vec128
  11. | Vec256
  12. | Vec512
  13. | Word
  14. | Product of mixed_product_shape
  15. | Void
and mixed_product_shape = mixed_block_element array
and type_origin =
  1. | Definition
  2. | Rec_check_regularity
  3. | Existential of string
and module_representation = Jkind_types.Sort.t array
and record_representation =
  1. | Record_unboxed
  2. | Record_inlined of tag * constructor_representation * variant_representation
  3. | Record_boxed of Jkind_types.Sort.Const.t array
  4. | Record_float
  5. | Record_ufloat
  6. | Record_mixed of mixed_product_shape
and record_unboxed_product_representation =
  1. | Record_unboxed_product
and variant_representation =
  1. | Variant_unboxed
  2. | Variant_boxed of (constructor_representation * Jkind_types.Sort.Const.t array) array
  3. | Variant_extensible
  4. | Variant_with_null
and constructor_representation =
  1. | Constructor_uniform_value
  2. | Constructor_mixed of mixed_product_shape
and label_declaration = {
  1. ld_id : Ident.t;
  2. ld_mutable : mutability;
  3. ld_modalities : Mode.Modality.Const.t;
  4. ld_type : type_expr;
  5. ld_sort : Jkind_types.Sort.Const.t;
  6. ld_loc : Ocaml_parsing.Location.t;
  7. ld_attributes : Ocaml_parsing.Parsetree.attributes;
  8. ld_uid : Uid.t;
}
and constructor_declaration = {
  1. cd_id : Ident.t;
  2. cd_args : constructor_arguments;
  3. cd_res : type_expr option;
  4. cd_loc : Ocaml_parsing.Location.t;
  5. cd_attributes : Ocaml_parsing.Parsetree.attributes;
  6. cd_uid : Uid.t;
}
and constructor_argument = {
  1. ca_modalities : Mode.Modality.Const.t;
  2. ca_type : type_expr;
  3. ca_sort : Jkind_types.Sort.Const.t;
  4. ca_loc : Ocaml_parsing.Location.t;
}
and constructor_arguments =
  1. | Cstr_tuple of constructor_argument list
  2. | Cstr_record of label_declaration list
val tys_of_constr_args : constructor_arguments -> type_expr list
val find_unboxed_type : type_declaration -> (type_expr * Mode.Modality.Const.t) option
type extension_constructor = {
  1. ext_type_path : Path.t;
  2. ext_type_params : type_expr list;
  3. ext_args : constructor_arguments;
  4. ext_shape : constructor_representation;
  5. ext_constant : bool;
  6. ext_ret_type : type_expr option;
  7. ext_private : Ocaml_parsing.Asttypes.private_flag;
  8. ext_loc : Ocaml_parsing.Location.t;
  9. ext_attributes : Ocaml_parsing.Parsetree.attributes;
  10. ext_uid : Uid.t;
}
and type_transparence =
  1. | Type_public
  2. | Type_new
  3. | Type_private
type class_type =
  1. | Cty_constr of Path.t * type_expr list * class_type
  2. | Cty_signature of class_signature
  3. | Cty_arrow of arg_label * type_expr * class_type
type class_declaration = {
  1. cty_params : type_expr list;
  2. mutable cty_type : class_type;
  3. cty_path : Path.t;
  4. cty_new : type_expr option;
  5. cty_variance : Variance.t list;
  6. cty_loc : Ocaml_parsing.Location.t;
  7. cty_attributes : Ocaml_parsing.Parsetree.attributes;
  8. cty_uid : Uid.t;
}
type class_type_declaration = {
  1. clty_params : type_expr list;
  2. clty_type : class_type;
  3. clty_path : Path.t;
  4. clty_hash_type : type_declaration;
  5. clty_variance : Variance.t list;
  6. clty_loc : Ocaml_parsing.Location.t;
  7. clty_attributes : Ocaml_parsing.Parsetree.attributes;
  8. clty_uid : Uid.t;
}
type visibility =
  1. | Exported
  2. | Hidden
type rec_status =
  1. | Trec_not
  2. | Trec_first
  3. | Trec_next
type ext_status =
  1. | Text_first
  2. | Text_next
  3. | Text_exception
type module_presence =
  1. | Mp_present
  2. | Mp_absent
module Aliasability : sig ... end
module type Wrap = sig ... end
module type Wrapped = sig ... end
module Make_wrapped (Wrap : Wrap) : Wrapped with type 'a wrapped = 'a Wrap.t
module Map_wrapped (From : Wrapped) (To : Wrapped) : sig ... end
include Wrapped with type 'a wrapped = 'a
type 'a wrapped = 'a
type value_description = {
  1. val_type : type_expr wrapped;
  2. val_modalities : Mode.Modality.t;
  3. val_kind : value_kind;
  4. val_loc : Ocaml_parsing.Location.t;
  5. val_zero_alloc : Zero_alloc.t;
  6. val_attributes : Ocaml_parsing.Parsetree.attributes;
  7. val_uid : Uid.t;
}
type module_type =
  1. | Mty_ident of Path.t
  2. | Mty_signature of signature
  3. | Mty_functor of functor_parameter * module_type
  4. | Mty_alias of Path.t
  5. | Mty_strengthen of module_type * Path.t * Aliasability.t
  6. | Mty_for_hole
and functor_parameter =
  1. | Unit
  2. | Named of Ident.t option * module_type
and signature = signature_item list wrapped
and module_declaration = {
  1. md_type : module_type;
  2. md_modalities : Mode.Modality.t;
  3. md_attributes : Ocaml_parsing.Parsetree.attributes;
  4. md_loc : Ocaml_parsing.Location.t;
  5. md_uid : Uid.t;
}
and modtype_declaration = {
  1. mtd_type : module_type option;
  2. mtd_attributes : Ocaml_parsing.Parsetree.attributes;
  3. mtd_loc : Ocaml_parsing.Location.t;
  4. mtd_uid : Uid.t;
}
val sort_of_signature_item : signature_item -> Jkind_types.Sort.t option
val item_visibility : signature_item -> visibility
type constructor_description = {
  1. cstr_name : string;
  2. cstr_res : type_expr;
  3. cstr_existentials : type_expr list;
  4. cstr_args : constructor_argument list;
  5. cstr_arity : int;
  6. cstr_tag : tag;
  7. cstr_repr : variant_representation;
  8. cstr_shape : constructor_representation;
  9. cstr_constant : bool;
  10. cstr_consts : int;
  11. cstr_nonconsts : int;
  12. cstr_generalized : bool;
  13. cstr_private : Ocaml_parsing.Asttypes.private_flag;
  14. cstr_loc : Ocaml_parsing.Location.t;
  15. cstr_attributes : Ocaml_parsing.Parsetree.attributes;
  16. cstr_inlined : type_declaration option;
  17. cstr_uid : Uid.t;
}
val equal_tag : tag -> tag -> bool
val compare_tag : tag -> tag -> int
val may_equal_constr : constructor_description -> constructor_description -> bool
val equal_record_representation : record_representation -> record_representation -> bool
val equal_record_unboxed_product_representation : record_unboxed_product_representation -> record_unboxed_product_representation -> bool
val equal_variant_representation : variant_representation -> variant_representation -> bool
type 'a gen_label_description = {
  1. lbl_name : string;
  2. lbl_res : type_expr;
  3. lbl_arg : type_expr;
  4. lbl_mut : mutability;
  5. lbl_modalities : Mode.Modality.Const.t;
  6. lbl_sort : Jkind_types.Sort.Const.t;
  7. lbl_pos : int;
  8. lbl_all : 'a gen_label_description array;
  9. lbl_repres : 'a;
  10. lbl_private : Ocaml_parsing.Asttypes.private_flag;
  11. lbl_loc : Ocaml_parsing.Location.t;
  12. lbl_attributes : Ocaml_parsing.Parsetree.attributes;
  13. lbl_uid : Uid.t;
}
type _ record_form =
  1. | Legacy : record_representation record_form
  2. | Unboxed_product : record_unboxed_product_representation record_form

This type tracks the distinction between legacy records ({ field }) and unboxed records (#{ field }). Note that Legacy includes normal boxed records, as well as inlined and [@@unboxed] records.

As a GADT, it also lets us avoid duplicating functions that handle both record forms, such as Env.find_label_by_name, which has type 'rep record_form -> Longident.t -> Env.t -> 'rep gen_label_description.

type record_form_packed =
  1. | P : _ record_form -> record_form_packed
val record_form_to_string : _ record_form -> string
val mixed_block_element_of_const_sort : Jkind_types.Sort.Const.t -> mixed_block_element
val bound_value_identifiers : signature -> Ident.t list

Extracts the list of "value" identifiers bound by a signature. "Value" identifiers are identifiers for signature components that correspond to a run-time value: values, extensions, modules, classes. Note: manifest primitives do not correspond to a run-time value!

val bound_value_identifiers_and_sorts : signature -> (Ident.t * Jkind_types.Sort.t) list

Like bound_value_identifiers, but also return sorts

val signature_item_id : signature_item -> Ident.t
val equal_mixed_block_element : mixed_block_element -> mixed_block_element -> bool
val compare_mixed_block_element : mixed_block_element -> mixed_block_element -> int
val mixed_block_element_to_string : mixed_block_element -> string
val mixed_block_element_to_lowercase_string : mixed_block_element -> string
val equal_unsafe_mode_crossing : type_equal:(type_expr -> type_expr -> bool) -> unsafe_mode_crossing -> unsafe_mode_crossing -> bool
type snapshot
val snapshot : unit -> snapshot
val backtrack : cleanup_abbrev:(unit -> unit) -> snapshot -> unit
val undo_first_change_after : snapshot -> unit
val undo_compress : snapshot -> unit

Functions to use when modifying a type (only Ctype?). The old values are logged and reverted on backtracking.

val set_type_desc : type_expr -> type_desc -> unit
val set_level : type_expr -> int -> unit
val set_scope : type_expr -> int -> unit
val set_var_jkind : type_expr -> jkind_lr -> unit
val set_name : (Path.t * type_expr list) option ref -> (Path.t * type_expr list) option -> unit
val set_univar : type_expr option ref -> type_expr -> unit
val set_commu_ok : commutable -> unit
val functor_param_mode : Mode.Alloc.lr
val functor_res_mode : Mode.Alloc.lr
val is_valid : snapshot -> bool

check if a snapshot has been invalidated

val on_backtrack : (unit -> unit) -> unit

also register changes to arbitrary references

val linked_variables : unit -> int

Number of unification variables that have been linked so far. Used to estimate the "cost" of unification.