jon.recoil.org

Module Typedtree

Abstract syntax tree after typing

By comparison with Parsetree:

module Uid = Shape.Uid
type constant =
  1. | Const_int of int
  2. | Const_char of char
  3. | Const_untagged_char of char
  4. | Const_string of string * Location.t * string option
  5. | Const_float of string
  6. | Const_float32 of string
  7. | Const_unboxed_float of string
  8. | Const_unboxed_float32 of string
  9. | Const_int8 of int
  10. | Const_int16 of int
  11. | Const_int32 of int32
  12. | Const_int64 of int64
  13. | Const_nativeint of nativeint
  14. | Const_untagged_int of int
  15. | Const_untagged_int8 of int
  16. | Const_untagged_int16 of int
  17. | Const_unboxed_int32 of int32
  18. | Const_unboxed_int64 of int64
  19. | Const_unboxed_nativeint of nativeint
type partial =
  1. | Partial
  2. | Total

Extension points

type attribute = Parsetree.attribute
type attributes = Typedtree.attribute list

Core language

type value =
  1. | Value_pattern
type computation =
  1. | Computation_pattern
module Unique_barrier : sig ... end

A unique barrier annotates field accesses (eg. Texp_field and patterns) with the uniqueness mode of the allocation that is projected out of. Projections out of unique allocations may not be pushed down in later stages of the compiler, because the unique allocation may be overwritten.

The uniqueness/linearity of a usage (such as Pexp_ident) inferred by the type checker. It is derived during type checking as follows: unique_use.uniqueness = expected_mode.uniqueness unique_use.linearity = actual_mode.linearity for example, let x = P in f x, (Pexp_ident x).unique_use will contain the expected uniqueness of f's parameter, and linearity of P. uniqueness_analysis.ml will _lexically_ infer the uniqueness/linearity of a usage and compare against unique_use. Following the example, if there are two f x, the uniqueness analysis will perform the following for unique_use of both Pexp_ident x: unique_use.uniqueness >= aliased unique_use.linearity <= many That is, the consumers of the values (that is f) must not require its parameter to be unique, and the value itself (that is P) must be many.

val print_unique_use : Stdlib.Format.formatter -> Typedtree.unique_use -> unit
type alloc_mode = Mode.Alloc.r
type texp_field_boxing =
  1. | Boxing of Typedtree.alloc_mode * Typedtree.unique_use
    (*

    Projection requires boxing. unique_use describes the usage of the unboxed field as argument to boxing.

    *)
  2. | Non_boxing of Typedtree.unique_use
    (*

    Projection does not require boxing. unique_use describes the usage of the field as the result of direct projection.

    *)
val aliased_many_use : Typedtree.unique_use
and 'a pattern_data = {
  1. pat_desc : 'a;
  2. pat_loc : Location.t;
  3. pat_extra : (Typedtree.pat_extra * Location.t * Typedtree.attributes) list;
  4. pat_type : Types.type_expr;
  5. pat_env : Env.t;
  6. pat_attributes : Typedtree.attributes;
  7. pat_unique_barrier : Typedtree.Unique_barrier.t;
    (*

    This tracks whether the scrutinee of the pattern is used uniquely within the body of the pattern match.

    *)
}
and pat_extra =
  1. | Tpat_constraint of Typedtree.core_type
    (*

    P : T pat_desc = P ; pat_extra = (Tpat_constraint T, _, _) :: ...

    *)
  2. | Tpat_type of Path.t * Longident.t Asttypes.loc
    (*

    #tconst pat_desc = disjunction ; pat_extra = (Tpat_type (P, "tconst"), _, _) :: ...

    where disjunction is a Tpat_or _ representing the branches of tconst.

    *)
  3. | Tpat_open of Path.t * Longident.t Asttypes.loc * Env.t
  4. | Tpat_unpack
    (*

    (module P) pat_desc = Tpat_var "P" ; pat_extra = (Tpat_unpack, _, _) :: ... (module _) pat_desc = Tpat_any ; pat_extra = (Tpat_unpack, _, _) :: ...

    *)
and 'k pattern_desc =
  1. | Tpat_any : Typedtree.value Typedtree.pattern_desc
    (*

    _

    *)
  2. | Tpat_var : Ident.t * string Asttypes.loc * Uid.t * Jkind_types.Sort.t * Mode.Value.l -> Typedtree.value Typedtree.pattern_desc
    (*

    x

    *)
  3. | Tpat_alias : Typedtree.value Typedtree.general_pattern * Ident.t * string Asttypes.loc * Uid.t * Jkind_types.Sort.t * Mode.Value.l * Types.type_expr -> Typedtree.value Typedtree.pattern_desc
    (*

    P as a

    *)
  4. | Tpat_constant : Typedtree.constant -> Typedtree.value Typedtree.pattern_desc
    (*

    1, 'a', "true", 1.0, 1l, 1L, 1n

    *)
  5. | Tpat_tuple : (string option * Typedtree.value Typedtree.general_pattern) list -> Typedtree.value Typedtree.pattern_desc
    (*

    (P1, ..., Pn) (None,P1); ...; (None,Pn)) (L1:P1, ... Ln:Pn) (Some L1,P1); ...; (Some Ln,Pn)) Any mix, e.g. (L1:P1, P2) (Some L1,P1); ...; (None,P2))

    Invariant: n >= 2

    *)
  6. | Tpat_unboxed_tuple : (string option * Typedtree.value Typedtree.general_pattern * Jkind.sort) list -> Typedtree.value Typedtree.pattern_desc
    (*

    #(P1, ..., Pn) (None,P1,s1); ...; (None,Pn,sn)) #(L1:P1, ... Ln:Pn) (Some L1,P1,s1); ...; (Some Ln,Pn,sn)) Any mix, e.g. #(L1:P1, P2) (Some L1,P1,s1); ...; (None,P2,s2))

    Invariant: n >= 2

    *)
  7. | Tpat_construct : Longident.t Asttypes.loc * Types.constructor_description * Typedtree.value Typedtree.general_pattern list * ((Ident.t Asttypes.loc * Parsetree.jkind_annotation option) list * Typedtree.core_type) option -> Typedtree.value Typedtree.pattern_desc
    (*

    C (, None) C P (P, None) C (P1, ..., Pn) (P1; ...; Pn, None) C (P : t) (P, Some (, t)) C (P1, ..., Pn : t) (P1; ...; Pn, Some (, t)) C (type a) (P : t) (P, Some (a, t)) C (type a) (P1, ..., Pn : t) (P1; ...; Pn, Some (a, None, t)) C (type (a : k)) (P1, ..., Pn : t) (P1; ...; Pn, Some (a, Some k, t))

    *)
  8. | Tpat_variant : Asttypes.label * Typedtree.value Typedtree.general_pattern option * Types.row_desc Stdlib.ref -> Typedtree.value Typedtree.pattern_desc
    (*

    `A (None) `A P (Some P)

    See Types.row_desc for an explanation of the last parameter.

    *)
  9. | Tpat_record : (Longident.t Asttypes.loc * Types.label_description * Typedtree.value Typedtree.general_pattern) list * Asttypes.closed_flag -> Typedtree.value Typedtree.pattern_desc
    (*

    l1=P1; ...; ln=Pn (flag = Closed) l1=P1; ...; ln=Pn; _ (flag = Open)

    Invariant: n > 0

    *)
  10. | Tpat_record_unboxed_product : (Longident.t Asttypes.loc * Types.unboxed_label_description * Typedtree.value Typedtree.general_pattern) list * Asttypes.closed_flag -> Typedtree.value Typedtree.pattern_desc
    (*

    # l1=P1; ...; ln=Pn (flag = Closed) # l1=P1; ...; ln=Pn; _ (flag = Open)

    Invariant: n > 0

    *)
  11. | Tpat_array : Types.mutability * Jkind.sort * Typedtree.value Typedtree.general_pattern list -> Typedtree.value Typedtree.pattern_desc
    (*

    | P1; ...; Pn | (flag = Mutable) : P1; ...; Pn : (flag = Immutable)

    *)
  12. | Tpat_lazy : Typedtree.value Typedtree.general_pattern -> Typedtree.value Typedtree.pattern_desc
    (*

    lazy P

    *)
  13. | Tpat_value : Typedtree.tpat_value_argument -> Typedtree.computation Typedtree.pattern_desc
    (*

    P

    Invariant: Tpat_value pattern should not carry pat_attributes or pat_extra metadata coming from user syntax, which must be on the inner pattern node -- to facilitate searching for a certain value pattern constructor with a specific attributed.

    To enforce this restriction, we made the argument of the Tpat_value constructor a private synonym of pattern, requiring you to use the as_computation_pattern function below instead of using the Tpat_value constructor directly.

    *)
  14. | Tpat_exception : Typedtree.value Typedtree.general_pattern -> Typedtree.computation Typedtree.pattern_desc
    (*

    exception P

    *)
  15. | Tpat_or : 'k Typedtree.general_pattern * 'k Typedtree.general_pattern * Types.row_desc option -> 'k Typedtree.pattern_desc
    (*

    P1 | P2

    row_desc = Some _ when translating Ppat_type _, None otherwise.

    *)
and tpat_value_argument = private Typedtree.value Typedtree.general_pattern
and expression = {
  1. exp_desc : Typedtree.expression_desc;
  2. exp_loc : Location.t;
  3. exp_extra : (Typedtree.exp_extra * Location.t * Typedtree.attributes) list;
  4. exp_type : Types.type_expr;
  5. exp_env : Env.t;
  6. exp_attributes : Typedtree.attributes;
}
and exp_extra =
  1. | Texp_constraint of Typedtree.core_type
    (*

    E : T

    *)
  2. | Texp_coerce of Typedtree.core_type option * Typedtree.core_type
    (*

    E :> T Texp_coerce (None, T) E : T0 :> T Texp_coerce (Some T0, T)

    *)
  3. | Texp_poly of Typedtree.core_type option
    (*

    Used for method bodies.

    *)
  4. | Texp_newtype of Ident.t * string Asttypes.loc * Parsetree.jkind_annotation option * Uid.t
    (*

    fun (type t : immediate) ->

    The Ident.t and Uid.t fields are unused by the compiler, but Merlin needs them. Merlin cannot be cleanly patched to include these fields because Merlin must be able to deserialize typedtrees produced by the compiler. Thus, we include them here, as the cost of tracking this additional information is minimal.

    *)
  5. | Texp_stack
    (*

    stack_ E

    *)
  6. | Texp_mode of Mode.Alloc.Const.Option.t
    (*

    E : _ @@ M

    *)
and arg_label = Types.arg_label =
  1. | Nolabel
  2. | Labelled of string
  3. | Optional of string
  4. | Position of string
and expression_desc =
  1. | Texp_ident of Path.t * Longident.t Asttypes.loc * Types.value_description * Typedtree.ident_kind * Typedtree.unique_use
    (*

    x M.x

    *)
  2. | Texp_constant of Typedtree.constant
    (*

    1, 'a', "true", 1.0, 1l, 1L, 1n

    *)
  3. | Texp_let of Asttypes.rec_flag * Typedtree.value_binding list * Typedtree.expression
    (*

    let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive) let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive)

    *)
  4. | Texp_letmutable of Typedtree.value_binding * Typedtree.expression
    (*

    let mutable P = E in E'

    *)
  5. | Texp_function of {
    1. params : Typedtree.function_param list;
    2. body : Typedtree.function_body;
    3. ret_mode : Mode.Alloc.l;
    4. ret_sort : Jkind.sort;
    5. alloc_mode : Typedtree.alloc_mode;
    6. zero_alloc : Zero_alloc.t;
    }
    (*

    fun P0 P1 -> function p1 -> e1 | p2 -> e2 (body = Tfunction_cases _) fun P0 P1 -> E (body = Tfunction_body _) This construct has the same arity as the originating Pexp_function. Arity determines when side-effects for effectful parameters are run (e.g. optional argument defaults, matching against lazy patterns). Parameters' effects are run left-to-right when an n-ary function is saturated with n arguments.

    *)
  6. | Texp_apply of Typedtree.expression * (Typedtree.arg_label * Typedtree.apply_arg) list * Typedtree.apply_position * Mode.Locality.l * Zero_alloc.assume option
    (*

    E0 ~l1:E1 ... ~ln:En

    The expression can be Omitted if the expression is abstracted over this argument. It currently appears when a label is applied.

    For example: let f x ~y = x + y in f ~y:3

    The resulting typedtree for the application is: Texp_apply (Texp_ident "f/1037", (Nolabel, Omitted _); (Labelled "y", Some (Texp_constant Const_int 3)) )

    The Zero_alloc.assume option records the optional @zero_alloc assume attribute that may appear on applications.

    *)
  7. | Texp_match of Typedtree.expression * Jkind.sort * Typedtree.computation Typedtree.case list * Typedtree.partial
    (*

    match E0 with | P1 -> E1 | P2 | exception P3 -> E2 | exception P4 -> E3

    Texp_match (E0, sort_of_E0, [(P1, E1); (P2 | exception P3, E2); (exception P4, E3)], _)

    *)
  8. | Texp_try of Typedtree.expression * Typedtree.value Typedtree.case list
    (*

    try E with P1 -> E1 | ... | PN -> EN

    *)
  9. | Texp_tuple of (string option * Typedtree.expression) list * Typedtree.alloc_mode
    (*

    Texp_tuple(el) represents

    • (E1, ..., En) when el is (None, E1);...;(None, En),
    • (L1:E1, ..., Ln:En) when el is (Some L1, E1);...;(Some Ln, En),
    • Any mix, e.g. (L1: E1, E2) when el is (Some L1, E1); (None, E2)
    *)
  10. | Texp_unboxed_tuple of (string option * Typedtree.expression * Jkind.sort) list
    (*

    Texp_unboxed_tuple(el) represents

    • #(E1, ..., En) when el is (None, E1, s1);...;(None, En, sn),
    • #(L1:E1, ..., Ln:En) when el is (Some L1, E1, s1);...;(Some Ln, En, sn),
    • Any mix, e.g. #(L1: E1, E2) when el is (Some L1, E1, s1); (None, E2, s2)
    *)
  11. | Texp_construct of Longident.t Asttypes.loc * Types.constructor_description * Typedtree.expression list * Typedtree.alloc_mode option
    (*

    C C E E C (E1, ..., En) E1;...;En

    alloc_mode is the allocation mode of the construct, or None if the constructor is Cstr_unboxed or Cstr_constant, in which case it does not need allocation.

    *)
  12. | Texp_variant of Asttypes.label * (Typedtree.expression * Typedtree.alloc_mode) option
    (*

    alloc_mode is the allocation mode of the variant, or None if the variant has no argument, in which case it does not need allocation.

    *)
  13. | Texp_record of {
    1. fields : (Types.label_description * Typedtree.record_label_definition) array;
    2. representation : Types.record_representation;
    3. extended_expression : (Typedtree.expression * Jkind.sort * Typedtree.Unique_barrier.t) option;
    4. alloc_mode : Typedtree.alloc_mode option;
    }
    (*

    l1=P1; ...; ln=Pn (extended_expression = None) E0 with l1=P1; ...; ln=Pn (extended_expression = Some E0)

    Invariant: n > 0

    If the type is l1: t1; l2: t2 , the expression E0 with t2=P2 is represented as Texp_record fields = [| l1, Kept t1; l2 Override P2 |]; representation; extended_expression = Some E0 alloc_mode is the allocation mode of the record, or None if it is Record_unboxed, in which case it does not need allocation.

    *)
  14. | Texp_record_unboxed_product of {
    1. fields : (Types.unboxed_label_description * Typedtree.record_label_definition) array;
    2. representation : Types.record_unboxed_product_representation;
    3. extended_expression : (Typedtree.expression * Jkind.sort) option;
    }
    (*

    # l1=P1; ...; ln=Pn (extended_expression = None) # E0 with l1=P1; ...; ln=Pn (extended_expression = Some E0)

    Invariant: n > 0

    If the type is # l1: t1; l2: t2 , the expression # E0 with t2=P2 is represented as Texp_record_unboxed_product fields = [| l1, Kept t1; l2 Override P2 |]; representation; extended_expression = Some E0

    *)
  15. | Texp_atomic_loc of Typedtree.expression * Jkind.sort * Longident.t Asttypes.loc * Types.label_description * Typedtree.alloc_mode
  16. | Texp_field of Typedtree.expression * Jkind.sort * Longident.t Asttypes.loc * Types.label_description * Typedtree.texp_field_boxing * Typedtree.Unique_barrier.t
    (*
    • The sort is the sort of the whole record (which may be non-value if the record is @

      @unboxed

      ).

    • texp_field_boxing provides extra information depending on if the projection requires boxing.
    *)
  17. | Texp_unboxed_field of Typedtree.expression * Jkind.sort * Longident.t Asttypes.loc * Types.unboxed_label_description * Typedtree.unique_use
  18. | Texp_setfield of Typedtree.expression * Mode.Locality.l * Longident.t Asttypes.loc * Types.label_description * Typedtree.expression
    (*

    alloc_mode translates to the modify_mode of the record

    *)
  19. | Texp_array of Types.mutability * Jkind.Sort.t * Typedtree.expression list * Typedtree.alloc_mode
  20. | Texp_idx of Typedtree.block_access * Typedtree.unboxed_access list
  21. | Texp_list_comprehension of Typedtree.comprehension
  22. | Texp_array_comprehension of Types.mutability * Jkind.sort * Typedtree.comprehension
  23. | Texp_ifthenelse of Typedtree.expression * Typedtree.expression * Typedtree.expression option
  24. | Texp_sequence of Typedtree.expression * Jkind.sort * Typedtree.expression
  25. | Texp_while of {
    1. wh_cond : Typedtree.expression;
    2. wh_body : Typedtree.expression;
    3. wh_body_sort : Jkind.sort;
    }
  26. | Texp_for of {
    1. for_id : Ident.t;
    2. for_debug_uid : Shape.Uid.t;
    3. for_pat : Parsetree.pattern;
    4. for_from : Typedtree.expression;
    5. for_to : Typedtree.expression;
    6. for_dir : Asttypes.direction_flag;
    7. for_body : Typedtree.expression;
    8. for_body_sort : Jkind.sort;
    }
  27. | Texp_send of Typedtree.expression * Typedtree.meth * Typedtree.apply_position
  28. | Texp_new of Path.t * Longident.t Asttypes.loc * Types.class_declaration * Typedtree.apply_position
  29. | Texp_instvar of Path.t * Path.t * string Asttypes.loc
  30. | Texp_mutvar of Ident.t Asttypes.loc
  31. | Texp_setinstvar of Path.t * Path.t * string Asttypes.loc * Typedtree.expression
  32. | Texp_setmutvar of Ident.t Asttypes.loc * Jkind.sort * Typedtree.expression
  33. | Texp_override of Path.t * (Ident.t * string Asttypes.loc * Typedtree.expression) list
  34. | Texp_letmodule of Ident.t option * string option Asttypes.loc * Types.module_presence * Typedtree.module_expr * Typedtree.expression
  35. | Texp_letexception of Typedtree.extension_constructor * Typedtree.expression
  36. | Texp_assert of Typedtree.expression * Location.t
  37. | Texp_lazy of Typedtree.expression
  38. | Texp_object of Typedtree.class_structure * string list
  39. | Texp_pack of Typedtree.module_expr
  40. | Texp_letop of {
    1. let_ : Typedtree.binding_op;
    2. ands : Typedtree.binding_op list;
    3. param : Ident.t;
    4. param_debug_uid : Shape.Uid.t;
    5. param_sort : Jkind.sort;
    6. body : Typedtree.value Typedtree.case;
    7. body_sort : Jkind.sort;
    8. partial : Typedtree.partial;
    }
  41. | Texp_unreachable
  42. | Texp_extension_constructor of Longident.t Asttypes.loc * Path.t
  43. | Texp_open of Typedtree.open_declaration * Typedtree.expression
    (*

    let open! M in e

    *)
  44. | Texp_probe of {
    1. name : string;
    2. handler : Typedtree.expression;
    3. enabled_at_init : bool;
    }
  45. | Texp_probe_is_enabled of {
    1. name : string;
    }
  46. | Texp_exclave of Typedtree.expression
  47. | Texp_src_pos
  48. | Texp_overwrite of Typedtree.expression * Typedtree.expression
    (*

    overwrite_ exp with exp

    *)
  49. | Texp_hole of Typedtree.unique_use
    (*

    _

    *)
  50. | Texp_quotation of Typedtree.expression
  51. | Texp_antiquotation of Typedtree.expression
  52. | Texp_eval of Typedtree.core_type * Jkind.sort

Jkinds in the typed tree: Compilation of the typed tree to lambda sometimes requires jkind information. Our approach is to propagate jkind information inward during compilation. This requires us to annotate places in the typed tree where the jkind of a type of a subexpression is not determined by the jkind of the type of the expression containing it. For example, to the left of a semicolon, or in value_bindings.

CR layouts v1.5: Some of these were mainly needed for void (e.g., left of a semicolon). If we redo how void is compiled, perhaps we can drop those. On the other hand, there are some places we're not annotating now (e.g., function arguments) that will need annotations in the future because we'll allow other jkinds there. Just do a rationalization pass on this.

and function_curry =
  1. | More_args of {
    1. partial_mode : Mode.Alloc.l;
    }
  2. | Final_arg
and function_param = {
  1. fp_arg_label : Typedtree.arg_label;
  2. fp_param : Ident.t;
    (*

    fp_param is the identifier that is to be used to name the parameter of the function.

    *)
  3. fp_param_debug_uid : Shape.Uid.t;
  4. fp_partial : Typedtree.partial;
    (*

    fp_partial = Partial if the pattern match is partial Total otherwise.

    *)
  5. fp_kind : Typedtree.function_param_kind;
  6. fp_sort : Jkind.sort;
  7. fp_mode : Mode.Alloc.l;
  8. fp_curry : Typedtree.function_curry;
  9. fp_newtypes : (Ident.t * string Asttypes.loc * Parsetree.jkind_annotation option * Uid.t) list;
    (*

    fp_newtypes are the new type declarations that come *after* that parameter. The newtypes that come before the first parameter are placed as exp_extras on the Texp_function node. This is just used in Untypeast.

    The Ident.t and Uid.t fields are unused by the compiler, but Merlin needs them. Merlin cannot be cleanly patched to include these fields because Merlin must be able to deserialize typedtrees produced by the compiler. Thus, we include them here, as the cost of tracking this additional information is minimal.

    *)
  10. fp_loc : Location.t;
    (*

    fp_loc is the location of the entire value parameter, not including the fp_newtypes.

    *)
}
and function_param_kind =
  1. | Tparam_pat of Typedtree.pattern
    (*

    Tparam_pat p is a non-optional argument with pattern p.

    *)
  2. | Tparam_optional_default of Typedtree.pattern * Typedtree.expression * Jkind.sort
    (*

    Tparam_optional_default (p, e, sort) is an optional argument p with default value e, i.e. ?x:(p = e). If the parameter is of type a option, the pattern and expression are of type a. sort is the sort of e.

    *)
and function_body =
  1. | Tfunction_body of Typedtree.expression
  2. | Tfunction_cases of Typedtree.function_cases
    (*

    The function body binds a final argument in Tfunction_cases, and this argument is pattern-matched against the cases.

    *)
and function_cases = {
  1. fc_cases : Typedtree.value Typedtree.case list;
  2. fc_env : Env.t;
    (*

    fc_env contains entries from all parameters except for the last one being matched by the cases.

    *)
  3. fc_arg_mode : Mode.Alloc.l;
  4. fc_arg_sort : Jkind.sort;
  5. fc_ret_type : Types.type_expr;
  6. fc_partial : Typedtree.partial;
  7. fc_param : Ident.t;
  8. fc_param_debug_uid : Shape.Uid.t;
  9. fc_loc : Location.t;
  10. fc_exp_extra : Typedtree.exp_extra option;
  11. fc_attributes : Typedtree.attributes;
    (*

    fc_attributes is just used in untypeast.

    *)
}
and ident_kind =
  1. | Id_value
  2. | Id_prim of Mode.Locality.l option * Jkind.Sort.t option
and meth =
  1. | Tmeth_name of string
  2. | Tmeth_val of Ident.t
  3. | Tmeth_ancestor of Ident.t * Path.t
and block_access =
  1. | Baccess_field of Longident.t Asttypes.loc * Types.label_description
  2. | Baccess_array of {
    1. mut : Asttypes.mutable_flag;
    2. index_kind : Asttypes.index_kind;
    3. index : Typedtree.expression;
    4. base_ty : Types.type_expr;
    5. elt_ty : Types.type_expr;
    6. elt_sort : Jkind.Sort.t;
    }
  3. | Baccess_block of Asttypes.mutable_flag * Typedtree.expression
and unboxed_access =
  1. | Uaccess_unboxed_field of Longident.t Asttypes.loc * Types.unboxed_label_description
and comprehension = {
  1. comp_body : Typedtree.expression;
  2. comp_clauses : Typedtree.comprehension_clause list;
}
and comprehension_clause =
  1. | Texp_comp_for of Typedtree.comprehension_clause_binding list
  2. | Texp_comp_when of Typedtree.expression
and comprehension_clause_binding = {
  1. comp_cb_iterator : Typedtree.comprehension_iterator;
  2. comp_cb_attributes : Typedtree.attribute list;
    (*

    No built-in attributes are meaningful here; this would correspond to [body for[@attr] x in xs], and there are no built-in attributes that would be efficacious there. (The only ones that might make sense would be inlining, but you can't do that with list/array items that are being iterated over.)

    *)
}

We move the pattern into the comprehension_iterator, compared to the untyped syntax tree, so that range-based iterators can have just an identifier instead of a full pattern

and comprehension_iterator =
  1. | Texp_comp_range of {
    1. ident : Ident.t;
    2. ident_debug_uid : Shape.Uid.t;
    3. pattern : Parsetree.pattern;
      (*

      Redundant with ident

      *)
    4. start : Typedtree.expression;
    5. stop : Typedtree.expression;
    6. direction : Asttypes.direction_flag;
    }
  2. | Texp_comp_in of {
    1. pattern : Typedtree.pattern;
    2. sequence : Typedtree.expression;
    }
and 'k case = {
  1. c_lhs : 'k Typedtree.general_pattern;
  2. c_guard : Typedtree.expression option;
  3. c_rhs : Typedtree.expression;
}
and record_label_definition =
  1. | Kept of Types.type_expr * Types.mutability * Typedtree.unique_use
  2. | Overridden of Longident.t Asttypes.loc * Typedtree.expression
and binding_op = {
  1. bop_op_path : Path.t;
  2. bop_op_name : string Asttypes.loc;
  3. bop_op_val : Types.value_description;
  4. bop_op_type : Types.type_expr;
  5. bop_op_return_sort : Jkind.sort;
  6. bop_exp : Typedtree.expression;
  7. bop_exp_sort : Jkind.sort;
  8. bop_loc : Location.t;
}
and ('a, 'b) arg_or_omitted =
  1. | Arg of 'a
  2. | Omitted of 'b
and omitted_parameter = {
  1. mode_closure : Mode.Alloc.r;
  2. mode_arg : Mode.Alloc.l;
  3. mode_ret : Mode.Alloc.l;
  4. sort_arg : Jkind.sort;
  5. sort_ret : Jkind.sort;
}
and apply_position =
  1. | Tail
  2. | Nontail
  3. | Default
and class_expr = {
  1. cl_desc : Typedtree.class_expr_desc;
  2. cl_loc : Location.t;
  3. cl_type : Types.class_type;
  4. cl_env : Env.t;
  5. cl_attributes : Typedtree.attributes;
}
and class_structure = {
  1. cstr_self : Typedtree.pattern;
  2. cstr_fields : Typedtree.class_field list;
  3. cstr_type : Types.class_signature;
  4. cstr_meths : Ident.t Types.Meths.t;
}
and class_field = {
  1. cf_desc : Typedtree.class_field_desc;
  2. cf_loc : Location.t;
  3. cf_attributes : Typedtree.attributes;
}
and class_field_kind =
  1. | Tcfk_virtual of Typedtree.core_type
  2. | Tcfk_concrete of Asttypes.override_flag * Typedtree.expression
and class_field_desc =
  1. | Tcf_inherit of Asttypes.override_flag * Typedtree.class_expr * string option * (string * Ident.t) list * (string * Ident.t) list
  2. | Tcf_val of string Asttypes.loc * Asttypes.mutable_flag * Ident.t * Typedtree.class_field_kind * bool
  3. | Tcf_method of string Asttypes.loc * Asttypes.private_flag * Typedtree.class_field_kind
  4. | Tcf_constraint of Typedtree.core_type * Typedtree.core_type
  5. | Tcf_initializer of Typedtree.expression
  6. | Tcf_attribute of Typedtree.attribute
and held_locks = Env.locks * Longident.t * Location.t
and mode_with_locks = Mode.Value.l * Typedtree.held_locks option
and module_expr = {
  1. mod_desc : Typedtree.module_expr_desc;
  2. mod_loc : Location.t;
  3. mod_type : Types.module_type;
  4. mod_mode : Typedtree.mode_with_locks;
    (*

    The mode of the module. The second component is Some if hold_locks is requested and the module is an identifier.

    *)
  5. mod_env : Env.t;
  6. mod_attributes : Typedtree.attributes;
}
and module_type_constraint =
  1. | Tmodtype_implicit
    (*

    The module type constraint has been synthesized during typechecking.

    *)
  2. | Tmodtype_explicit of Typedtree.module_type
    (*

    The module type was in the source file.

    *)

Annotations for Tmod_constraint.

and functor_parameter =
  1. | Unit
  2. | Named of Ident.t option * string option Asttypes.loc * Typedtree.module_type
and module_expr_desc =
  1. | Tmod_ident of Path.t * Longident.t Asttypes.loc
  2. | Tmod_structure of Typedtree.structure
  3. | Tmod_functor of Typedtree.functor_parameter * Typedtree.module_expr
  4. | Tmod_apply of Typedtree.module_expr * Typedtree.module_expr * Typedtree.module_coercion
  5. | Tmod_apply_unit of Typedtree.module_expr
  6. | Tmod_constraint of Typedtree.module_expr * Types.module_type * Typedtree.module_type_constraint * Typedtree.module_coercion
    (*

    ME (constraint = Tmodtype_implicit) (ME : MT) (constraint = Tmodtype_explicit MT)

    *)
  7. | Tmod_unpack of Typedtree.expression * Types.module_type
and structure = {
  1. str_items : Typedtree.structure_item list;
  2. str_type : Types.signature;
  3. str_final_env : Env.t;
}
and structure_item = {
  1. str_desc : Typedtree.structure_item_desc;
  2. str_loc : Location.t;
  3. str_env : Env.t;
}
and structure_item_desc =
  1. | Tstr_eval of Typedtree.expression * Jkind.sort * Typedtree.attributes
  2. | Tstr_value of Asttypes.rec_flag * Typedtree.value_binding list
  3. | Tstr_primitive of Typedtree.value_description
  4. | Tstr_type of Asttypes.rec_flag * Typedtree.type_declaration list
  5. | Tstr_typext of Typedtree.type_extension
  6. | Tstr_exception of Typedtree.type_exception
  7. | Tstr_module of Typedtree.module_binding
  8. | Tstr_recmodule of Typedtree.module_binding list
  9. | Tstr_modtype of Typedtree.module_type_declaration
  10. | Tstr_open of Typedtree.open_declaration
  11. | Tstr_class of (Typedtree.class_declaration * string list) list
  12. | Tstr_class_type of (Ident.t * string Asttypes.loc * Typedtree.class_type_declaration) list
  13. | Tstr_include of Typedtree.include_declaration
  14. | Tstr_attribute of Typedtree.attribute
and module_binding = {
  1. mb_id : Ident.t option;
    (*

    None for module _ = struct ... end

    *)
  2. mb_name : string option Asttypes.loc;
  3. mb_uid : Uid.t;
  4. mb_presence : Types.module_presence;
  5. mb_expr : Typedtree.module_expr;
  6. mb_attributes : Typedtree.attributes;
  7. mb_loc : Location.t;
}
and value_binding = {
  1. vb_pat : Typedtree.pattern;
  2. vb_expr : Typedtree.expression;
  3. vb_rec_kind : Value_rec_types.recursive_binding_kind;
  4. vb_sort : Jkind.sort;
  5. vb_attributes : Typedtree.attributes;
  6. vb_loc : Location.t;
}
and module_coercion =
  1. | Tcoerce_none
  2. | Tcoerce_structure of {
    1. input_repr : Types.module_representation;
    2. output_repr : Types.module_representation;
    3. pos_cc_list : (int * Typedtree.module_coercion) list;
    4. id_pos_list : (Ident.t * int * Typedtree.module_coercion) list;
    }
  3. | Tcoerce_functor of Typedtree.module_coercion * Typedtree.module_coercion
  4. | Tcoerce_primitive of Typedtree.primitive_coercion
    (*

    External declaration coerced to a regular value.

      module M : sig val ext : a -> b end =
      struct external ext : a -> b = "my_c_function" end

    Only occurs inside a Tcoerce_structure coercion.

    *)
  5. | Tcoerce_alias of Env.t * Path.t * Typedtree.module_coercion
    (*

    Module alias coerced to a regular module.

      module M : sig module Sub : T end =
      struct module Sub = Some_alias end

    Only occurs inside a Tcoerce_structure coercion.

    *)
and module_type = {
  1. mty_desc : Typedtree.module_type_desc;
  2. mty_type : Types.module_type;
  3. mty_env : Env.t;
  4. mty_loc : Location.t;
  5. mty_attributes : Typedtree.attributes;
}
and module_type_desc =
  1. | Tmty_ident of Path.t * Longident.t Asttypes.loc
  2. | Tmty_signature of Typedtree.signature
  3. | Tmty_functor of Typedtree.functor_parameter * Typedtree.module_type
  4. | Tmty_with of Typedtree.module_type * (Path.t * Longident.t Asttypes.loc * Typedtree.with_constraint) list
  5. | Tmty_typeof of Typedtree.module_expr
  6. | Tmty_alias of Path.t * Longident.t Asttypes.loc
  7. | Tmty_strengthen of Typedtree.module_type * Path.t * Longident.t Asttypes.loc
and primitive_coercion = {
  1. pc_desc : Primitive.description;
  2. pc_type : Types.type_expr;
  3. pc_poly_mode : Mode.Locality.l option;
  4. pc_poly_sort : Jkind.Sort.t option;
  5. pc_env : Env.t;
  6. pc_loc : Location.t;
}
and signature = {
  1. sig_items : Typedtree.signature_item list;
  2. sig_modalities : Mode.Modality.Const.t;
  3. sig_type : Types.signature;
  4. sig_final_env : Env.t;
  5. sig_sloc : Location.t;
}
and signature_item = {
  1. sig_desc : Typedtree.signature_item_desc;
  2. sig_env : Env.t;
  3. sig_loc : Location.t;
}
and signature_item_desc =
  1. | Tsig_value of Typedtree.value_description
  2. | Tsig_type of Asttypes.rec_flag * Typedtree.type_declaration list
  3. | Tsig_typesubst of Typedtree.type_declaration list
  4. | Tsig_typext of Typedtree.type_extension
  5. | Tsig_exception of Typedtree.type_exception
  6. | Tsig_module of Typedtree.module_declaration
  7. | Tsig_modsubst of Typedtree.module_substitution
  8. | Tsig_recmodule of Typedtree.module_declaration list
  9. | Tsig_modtype of Typedtree.module_type_declaration
  10. | Tsig_modtypesubst of Typedtree.module_type_declaration
  11. | Tsig_open of Typedtree.open_description
  12. | Tsig_include of Typedtree.include_description * Mode.Modality.Const.t
  13. | Tsig_class of Typedtree.class_description list
  14. | Tsig_class_type of Typedtree.class_type_declaration list
  15. | Tsig_attribute of Typedtree.attribute
and module_declaration = {
  1. md_id : Ident.t option;
  2. md_name : string option Asttypes.loc;
  3. md_uid : Uid.t;
  4. md_presence : Types.module_presence;
  5. md_type : Typedtree.module_type;
  6. md_modalities : Mode.Modality.t;
  7. md_attributes : Typedtree.attributes;
  8. md_loc : Location.t;
}
and module_substitution = {
  1. ms_id : Ident.t;
  2. ms_name : string Asttypes.loc;
  3. ms_uid : Uid.t;
  4. ms_manifest : Path.t;
  5. ms_txt : Longident.t Asttypes.loc;
  6. ms_attributes : Typedtree.attributes;
  7. ms_loc : Location.t;
}
and module_type_declaration = {
  1. mtd_id : Ident.t;
  2. mtd_name : string Asttypes.loc;
  3. mtd_uid : Uid.t;
  4. mtd_type : Typedtree.module_type option;
  5. mtd_attributes : Typedtree.attributes;
  6. mtd_loc : Location.t;
}
and 'a open_infos = {
  1. open_expr : 'a;
  2. open_bound_items : Types.signature;
  3. open_items_repr : Types.module_representation;
  4. open_override : Asttypes.override_flag;
  5. open_env : Env.t;
  6. open_loc : Location.t;
  7. open_attributes : Typedtree.attribute list;
}
and include_kind =
  1. | Tincl_structure
  2. | Tincl_functor of {
    1. input_coercion : (Ident.t * Typedtree.module_coercion) list;
    2. input_repr : Types.module_representation;
    }
  3. | Tincl_gen_functor of {
    1. input_coercion : (Ident.t * Typedtree.module_coercion) list;
    2. input_repr : Types.module_representation;
    }
and 'a include_infos = {
  1. incl_mod : 'a;
  2. incl_type : Types.signature;
  3. incl_repr : Types.module_representation;
  4. incl_loc : Location.t;
  5. incl_kind : Typedtree.include_kind;
  6. incl_attributes : Typedtree.attribute list;
}
and with_constraint =
  1. | Twith_type of Typedtree.type_declaration
  2. | Twith_module of Path.t * Longident.t Asttypes.loc
  3. | Twith_modtype of Typedtree.module_type
  4. | Twith_typesubst of Typedtree.type_declaration
  5. | Twith_modsubst of Path.t * Longident.t Asttypes.loc
  6. | Twith_modtypesubst of Typedtree.module_type
and core_type = {
  1. mutable ctyp_desc : Typedtree.core_type_desc;
    (*

    mutable because of Typeclass.declare_method

    *)
  2. mutable ctyp_type : Types.type_expr;
    (*

    mutable because of Typeclass.declare_method

    *)
  3. ctyp_env : Env.t;
  4. ctyp_loc : Location.t;
  5. ctyp_attributes : Typedtree.attributes;
}
and core_type_desc =
  1. | Ttyp_var of string option * Parsetree.jkind_annotation option
  2. | Ttyp_arrow of Typedtree.arg_label * Typedtree.core_type * Typedtree.core_type
  3. | Ttyp_tuple of (string option * Typedtree.core_type) list
  4. | Ttyp_unboxed_tuple of (string option * Typedtree.core_type) list
  5. | Ttyp_constr of Path.t * Longident.t Asttypes.loc * Typedtree.core_type list
  6. | Ttyp_object of Typedtree.object_field list * Asttypes.closed_flag
  7. | Ttyp_class of Path.t * Longident.t Asttypes.loc * Typedtree.core_type list
  8. | Ttyp_alias of Typedtree.core_type * string Asttypes.loc option * Parsetree.jkind_annotation option
  9. | Ttyp_variant of Typedtree.row_field list * Asttypes.closed_flag * Asttypes.label list option
  10. | Ttyp_poly of (string * Parsetree.jkind_annotation option) list * Typedtree.core_type
  11. | Ttyp_package of Typedtree.package_type
  12. | Ttyp_open of Path.t * Longident.t Asttypes.loc * Typedtree.core_type
  13. | Ttyp_quote of Typedtree.core_type
  14. | Ttyp_splice of Typedtree.core_type
  15. | Ttyp_of_kind of Parsetree.jkind_annotation
  16. | Ttyp_call_pos
    (*

    Ttyp_call_pos represents the type of the value of a Position argument (lbl:[%call_pos] -> ...).

    *)
and package_type = {
  1. pack_path : Path.t;
  2. pack_fields : (Longident.t Asttypes.loc * Typedtree.core_type) list;
  3. pack_type : Types.module_type;
  4. pack_txt : Longident.t Asttypes.loc;
}
and row_field = {
  1. rf_desc : Typedtree.row_field_desc;
  2. rf_loc : Location.t;
  3. rf_attributes : Typedtree.attributes;
}
and row_field_desc =
  1. | Ttag of string Asttypes.loc * bool * Typedtree.core_type list
  2. | Tinherit of Typedtree.core_type
and object_field = {
  1. of_desc : Typedtree.object_field_desc;
  2. of_loc : Location.t;
  3. of_attributes : Typedtree.attributes;
}
and object_field_desc =
  1. | OTtag of string Asttypes.loc * Typedtree.core_type
  2. | OTinherit of Typedtree.core_type
and value_description = {
  1. val_id : Ident.t;
  2. val_name : string Asttypes.loc;
  3. val_desc : Typedtree.core_type;
  4. val_val : Types.value_description;
  5. val_prim : string list;
  6. val_loc : Location.t;
  7. val_attributes : Typedtree.attributes;
}
and type_declaration = {
  1. typ_id : Ident.t;
  2. typ_name : string Asttypes.loc;
  3. typ_params : (Typedtree.core_type * (Asttypes.variance * Asttypes.injectivity)) list;
  4. typ_type : Types.type_declaration;
  5. typ_cstrs : (Typedtree.core_type * Typedtree.core_type * Location.t) list;
  6. typ_kind : Typedtree.type_kind;
  7. typ_private : Asttypes.private_flag;
  8. typ_manifest : Typedtree.core_type option;
  9. typ_loc : Location.t;
  10. typ_attributes : Typedtree.attributes;
  11. typ_jkind_annotation : Parsetree.jkind_annotation option;
}
and type_kind =
  1. | Ttype_abstract
  2. | Ttype_variant of Typedtree.constructor_declaration list
  3. | Ttype_record of Typedtree.label_declaration list
  4. | Ttype_record_unboxed_product of Typedtree.label_declaration list
  5. | Ttype_open
and label_declaration = {
  1. ld_id : Ident.t;
  2. ld_name : string Asttypes.loc;
  3. ld_uid : Uid.t;
  4. ld_mutable : Types.mutability;
  5. ld_modalities : Mode.Modality.Const.t;
  6. ld_type : Typedtree.core_type;
  7. ld_loc : Location.t;
  8. ld_attributes : Typedtree.attributes;
}
and constructor_declaration = {
  1. cd_id : Ident.t;
  2. cd_name : string Asttypes.loc;
  3. cd_uid : Uid.t;
  4. cd_vars : (string * Parsetree.jkind_annotation option) list;
  5. cd_args : Typedtree.constructor_arguments;
  6. cd_res : Typedtree.core_type option;
  7. cd_loc : Location.t;
  8. cd_attributes : Typedtree.attributes;
}
and constructor_argument = {
  1. ca_modalities : Mode.Modality.Const.t;
  2. ca_type : Typedtree.core_type;
  3. ca_loc : Location.t;
}
and constructor_arguments =
  1. | Cstr_tuple of Typedtree.constructor_argument list
  2. | Cstr_record of Typedtree.label_declaration list
and type_extension = {
  1. tyext_path : Path.t;
  2. tyext_txt : Longident.t Asttypes.loc;
  3. tyext_params : (Typedtree.core_type * (Asttypes.variance * Asttypes.injectivity)) list;
  4. tyext_constructors : Typedtree.extension_constructor list;
  5. tyext_private : Asttypes.private_flag;
  6. tyext_loc : Location.t;
  7. tyext_attributes : Typedtree.attributes;
}
and type_exception = {
  1. tyexn_constructor : Typedtree.extension_constructor;
  2. tyexn_loc : Location.t;
  3. tyexn_attributes : Typedtree.attribute list;
}
and extension_constructor = {
  1. ext_id : Ident.t;
  2. ext_name : string Asttypes.loc;
  3. ext_type : Types.extension_constructor;
  4. ext_kind : Typedtree.extension_constructor_kind;
  5. ext_loc : Location.t;
  6. ext_attributes : Typedtree.attributes;
}
and extension_constructor_kind =
  1. | Text_decl of (string * Parsetree.jkind_annotation option) list * Typedtree.constructor_arguments * Typedtree.core_type option
  2. | Text_rebind of Path.t * Longident.t Asttypes.loc
and class_type = {
  1. cltyp_desc : Typedtree.class_type_desc;
  2. cltyp_type : Types.class_type;
  3. cltyp_env : Env.t;
  4. cltyp_loc : Location.t;
  5. cltyp_attributes : Typedtree.attributes;
}
and class_signature = {
  1. csig_self : Typedtree.core_type;
  2. csig_fields : Typedtree.class_type_field list;
  3. csig_type : Types.class_signature;
}
and class_type_field = {
  1. ctf_desc : Typedtree.class_type_field_desc;
  2. ctf_loc : Location.t;
  3. ctf_attributes : Typedtree.attributes;
}
and class_type_field_desc =
  1. | Tctf_inherit of Typedtree.class_type
  2. | Tctf_val of string * Asttypes.mutable_flag * Asttypes.virtual_flag * Typedtree.core_type
  3. | Tctf_method of string * Asttypes.private_flag * Asttypes.virtual_flag * Typedtree.core_type
  4. | Tctf_constraint of Typedtree.core_type * Typedtree.core_type
  5. | Tctf_attribute of Typedtree.attribute
and class_type_declaration = Typedtree.class_type Typedtree.class_infos
and 'a class_infos = {
  1. ci_virt : Asttypes.virtual_flag;
  2. ci_params : (Typedtree.core_type * (Asttypes.variance * Asttypes.injectivity)) list;
  3. ci_id_name : string Asttypes.loc;
  4. ci_id_class : Ident.t;
  5. ci_id_class_type : Ident.t;
  6. ci_id_object : Ident.t;
  7. ci_expr : 'a;
  8. ci_decl : Types.class_declaration;
  9. ci_type_decl : Types.class_type_declaration;
  10. ci_loc : Location.t;
  11. ci_attributes : Typedtree.attributes;
}
type argument_interface = {
  1. ai_signature : Types.signature;
  2. ai_coercion_from_primary : Typedtree.module_coercion;
}

For a module M compiled with -as-argument-for P for some parameter module P, the signature of P along with the coercion from M's exported signature (the _primary interface_) to P's signature (the _argument interface_).

type implementation = {
  1. structure : Typedtree.structure;
  2. coercion : Typedtree.module_coercion;
  3. signature : Types.signature;
  4. argument_interface : Typedtree.argument_interface option;
  5. shape : Shape.t;
}

A typechecked implementation including its module structure, its exported signature, and a coercion of the module against that signature.

If an .mli file is present, the signature will come from that file and be the exported signature of the module.

If there isn't one, the signature will be inferred from the module structure.

If the module is compiled with -as-argument-for and is thus typechecked against the .mli for a parameter in addition to its own .mli, it has an additional signature stored in argument_interface.

type item_declaration =
  1. | Value of Typedtree.value_description
  2. | Value_binding of Typedtree.value_binding
  3. | Type of Typedtree.type_declaration
  4. | Constructor of Typedtree.constructor_declaration
  5. | Extension_constructor of Typedtree.extension_constructor
  6. | Label of Typedtree.label_declaration
  7. | Module of Typedtree.module_declaration
  8. | Module_substitution of Typedtree.module_substitution
  9. | Module_binding of Typedtree.module_binding
  10. | Module_type of Typedtree.module_type_declaration
  11. | Class of Typedtree.class_declaration
  12. | Class_type of Typedtree.class_type_declaration
    (*

    item_declaration groups together items that correspond to the syntactic category of "declarations" which include types, values, modules, etc. declarations in signatures and their definitions in implementations.

    *)

as_computation_pattern p is a computation pattern with description Tpat_value p, which enforces a correct placement of pat_attributes and pat_extra metadata (on the inner value pattern, rather than on the computation pattern).

val classify_pattern_desc : 'k Typedtree.pattern_desc -> 'k Typedtree.pattern_category
type pattern_action = {
  1. f : 'k. 'k Typedtree.general_pattern -> unit;
}
val shallow_iter_pattern_desc : Typedtree.pattern_action -> 'k Typedtree.pattern_desc -> unit
type pattern_transformation = {
  1. f : 'k. 'k Typedtree.general_pattern -> 'k Typedtree.general_pattern;
}
val iter_general_pattern : Typedtree.pattern_action -> 'k Typedtree.general_pattern -> unit
val iter_pattern : (Typedtree.pattern -> unit) -> Typedtree.pattern -> unit
type pattern_predicate = {
  1. f : 'k. 'k Typedtree.general_pattern -> bool;
}
val exists_general_pattern : Typedtree.pattern_predicate -> 'k Typedtree.general_pattern -> bool
val exists_pattern : (Typedtree.pattern -> bool) -> Typedtree.pattern -> bool
val let_bound_idents : Typedtree.value_binding list -> Ident.t list
val let_bound_idents_with_sorts : Typedtree.value_binding list -> (Ident.t * Jkind.Sort.t) list
val let_bound_idents_full : Typedtree.value_binding list -> (Ident.t * string Asttypes.loc * Types.type_expr * Jkind.Sort.t * Uid.t) list
val let_bound_idents_with_modes_sorts_and_checks : Typedtree.value_binding list -> (Ident.t * (Location.t * Mode.Value.l * Jkind.sort) list * Zero_alloc.t) list

Alpha conversion of patterns

val mknoloc : 'a -> 'a Asttypes.loc
val mkloc : 'a -> Location.t -> 'a Asttypes.loc
val pat_bound_idents : 'k Typedtree.general_pattern -> Ident.t list
val pat_bound_idents_full : 'k Typedtree.general_pattern -> (Ident.t * string Asttypes.loc * Types.type_expr * Types.Uid.t * Jkind.Sort.Const.t) list

Splits an or pattern into its value (left) and exception (right) parts.

val exp_is_nominal : Typedtree.expression -> bool

Whether an expression looks nice as the subject of a sentence in a error message.

val function_arity : Typedtree.function_param list -> Typedtree.function_body -> int

Calculates the syntactic arity of a function based on its parameters and body.

val loc_of_decl : uid:Shape.Uid.t -> Typedtree.item_declaration -> string Location.loc

Given a declaration, return the location of the bound identifier

val min_mode_with_locks : Typedtree.mode_with_locks

When type checking F(M).t, which does not involve modes, we say F(M) is of the strongest mode, to avoid modes in error messages.

val mode_without_locks_exn : Typedtree.mode_with_locks -> Mode.Value.l

Get the mode, asserting no held locks.

val fold_antiquote_exp : ('a -> Typedtree.expression -> 'a) -> 'a -> Typedtree.expression -> 'a

Fold over the antiquotations in an expression. This function defines the evaluation order of antiquotations.