jon.recoil.org

Module Ocaml_typing.Ctype

exception Cannot_expand
exception Cannot_apply
exception Incompatible
val with_local_level : ?post:('a -> unit) -> (unit -> 'a) -> 'a
val with_local_level_if : bool -> (unit -> 'a) -> post:('a -> unit) -> 'a
val with_local_level_iter : (unit -> 'a * 'b list) -> post:('b -> unit) -> 'a
val with_local_level_iter_if : bool -> (unit -> 'a * 'b list) -> post:('b -> unit) -> 'a
val with_level : level:int -> (unit -> 'a) -> 'a
val with_level_if : bool -> level:int -> (unit -> 'a) -> 'a
val with_local_level_if_principal : (unit -> 'a) -> post:('a -> unit) -> 'a
val with_local_level_iter_if_principal : (unit -> 'a * 'b list) -> post:('b -> unit) -> 'a
val with_local_level_for_class : ?post:('a -> unit) -> (unit -> 'a) -> 'a
val with_raised_nongen_level : (unit -> 'a) -> 'a
val reset_global_level : unit -> unit
val increase_global_level : unit -> int
val restore_global_level : int -> unit
type levels = {
  1. current_level : int;
  2. nongen_level : int;
  3. global_level : int;
  4. saved_level : (int * int) list;
}
val save_levels : unit -> Ocaml_typing.Ctype.levels
val set_levels : Ocaml_typing.Ctype.levels -> unit
val create_scope : unit -> int
val newvar2 : ?name:string -> int -> Ocaml_typing.Types.jkind_lr -> Ocaml_typing.Types.type_expr
val new_global_var : ?name:string -> Ocaml_typing.Types.jkind_lr -> Ocaml_typing.Types.type_expr

Transform a field type into a list of pairs label-type. The fields are sorted.

Beware of the interaction with GADTs:

Due to the introduction of object indexes for GADTs, the row variable of an object may now be an expansible type abbreviation. A first consequence is that flatten_fields will not completely flatten the object, since the type abbreviation will not be expanded (flatten_fields does not receive the current environment). Another consequence is that various functions may be called with the expansion of this type abbreviation, which is a Tfield, e.g. during printing.

Concrete problems have been fixed, but new bugs may appear in the future. (Test cases were added to typing-gadts/test.ml)

val opened_object : Ocaml_typing.Types.type_expr -> bool
val remove_object_name : Ocaml_typing.Types.type_expr -> unit
val generalize : Ocaml_typing.Types.type_expr -> unit
val lower_contravariant : Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr -> unit
val lower_variables_only : Ocaml_typing.Env.t -> int -> Ocaml_typing.Types.type_expr -> unit
val enforce_current_level : Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr -> unit
val generalize_structure : Ocaml_typing.Types.type_expr -> unit
val generalize_class_type : Ocaml_typing.Types.class_type -> unit
val generalize_class_type_structure : Ocaml_typing.Types.class_type -> unit
val generalize_class_signature_spine : Ocaml_typing.Env.t -> Ocaml_typing.Types.class_signature -> unit
val limited_generalize_class_type : Ocaml_typing.Types.type_expr -> Ocaml_typing.Types.class_type -> unit
val fully_generic : Ocaml_typing.Types.type_expr -> bool
val check_scope_escape : Ocaml_typing.Env.t -> int -> Ocaml_typing.Types.type_expr -> unit
module Pattern_env : sig ... end
type existential_treatment =
  1. | Keep_existentials_flexible
  2. | Make_existentials_abstract of Ocaml_typing.Ctype.Pattern_env.t
val instance_parameterized_type : ?keep_names:bool -> Ocaml_typing.Types.type_expr list -> Ocaml_typing.Types.type_expr -> Ocaml_typing.Types.type_expr list * Ocaml_typing.Types.type_expr

Given (a @ m1 -> b -> c) @ m0, where m0 and m1 are modes expressed by user-syntax, curry_mode m0 m1 gives the mode we implicitly interpret b->c to have.

The compiler's own version of expand_head necessary for type-based optimisations.

Expansion of types for error traces; lives here instead of in Errortrace because the expansion machinery lives here.

Create an Errortrace.Diff by expanding the two types

Create an Errortrace.Diff by *duplicating* the two types, so that each one's expansion is identical to itself. Despite the name, does create Errortrace.expanded_types.

val full_expand : may_forget_scope:bool -> Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr -> Ocaml_typing.Types.type_expr
type typedecl_extraction_result =
  1. | Typedecl of Ocaml_typing.Path.t * Ocaml_typing.Path.t * Ocaml_typing.Types.type_declaration
  2. | Has_no_typedecl
  3. | May_have_typedecl
val deep_occur_list : Ocaml_typing.Types.type_expr -> Ocaml_typing.Types.type_expr list -> bool
val all_distinct_vars : Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr list -> bool
type matches_result =
  1. | Unification_failure of Ocaml_typing.Errortrace.unification_error
  2. | Jkind_mismatch of {
    1. original_jkind : Ocaml_typing.Types.jkind_lr;
    2. inferred_jkind : Ocaml_typing.Types.jkind_lr;
    3. ty : Ocaml_typing.Types.type_expr;
    }
  3. | All_good
type filter_arrow_failure =
  1. | Unification_error of Ocaml_typing.Errortrace.unification_error
  2. | Label_mismatch of {
    1. got : Ocaml_typing.Types.arg_label;
    2. expected : Ocaml_typing.Types.arg_label;
    3. expected_type : Ocaml_typing.Types.type_expr;
    }
  3. | Not_a_function
  4. | Jkind_error of Ocaml_typing.Types.type_expr * Ocaml_typing.Jkind.Violation.t
exception Filter_arrow_failed of Ocaml_typing.Ctype.filter_arrow_failure
exception Filter_mono_failed
exception Filter_arrow_mono_failed
type filter_method_failure =
  1. | Unification_error of Ocaml_typing.Errortrace.unification_error
  2. | Not_a_method
  3. | Not_an_object of Ocaml_typing.Types.type_expr
  4. | Not_a_value of Ocaml_typing.Jkind.Violation.t
exception Filter_method_failed of Ocaml_typing.Ctype.filter_method_failure
type class_match_failure =
  1. | CM_Virtual_class
  2. | CM_Parameter_arity_mismatch of int * int
  3. | CM_Type_parameter_mismatch of int * Ocaml_typing.Env.t * Ocaml_typing.Errortrace.equality_error
  4. | CM_Class_type_mismatch of Ocaml_typing.Env.t * Ocaml_typing.Types.class_type * Ocaml_typing.Types.class_type
  5. | CM_Parameter_mismatch of int * Ocaml_typing.Env.t * Ocaml_typing.Errortrace.moregen_error
  6. | CM_Val_type_mismatch of string * Ocaml_typing.Env.t * Ocaml_typing.Errortrace.comparison_error
  7. | CM_Meth_type_mismatch of string * Ocaml_typing.Env.t * Ocaml_typing.Errortrace.comparison_error
  8. | CM_Non_mutable_value of string
  9. | CM_Non_concrete_value of string
  10. | CM_Missing_value of string
  11. | CM_Missing_method of string
  12. | CM_Hide_public of string
  13. | CM_Hide_virtual of string * string
  14. | CM_Public_method of string
  15. | CM_Private_method of string
  16. | CM_Virtual_method of string
val equal : ?do_jkind_check:bool -> Ocaml_typing.Env.t -> bool -> Ocaml_typing.Types.type_expr list -> Ocaml_typing.Types.type_expr list -> unit
module Rigidify : sig ... end
val new_class_signature : unit -> Ocaml_typing.Types.class_signature
val add_dummy_method : Ocaml_typing.Env.t -> scope:int -> Ocaml_typing.Types.class_signature -> unit
type add_method_failure =
  1. | Unexpected_method
  2. | Type_mismatch of Ocaml_typing.Errortrace.unification_error
exception Add_method_failed of Ocaml_typing.Ctype.add_method_failure
type add_instance_variable_failure =
  1. | Mutability_mismatch of Ocaml_parsing.Asttypes.mutable_flag
  2. | Type_mismatch of Ocaml_typing.Errortrace.unification_error
exception Add_instance_variable_failed of Ocaml_typing.Ctype.add_instance_variable_failure
exception Inherit_class_signature_failed of Ocaml_typing.Ctype.inherit_class_signature_failure
val inherit_class_signature : strict:bool -> Ocaml_typing.Env.t -> Ocaml_typing.Types.class_signature -> Ocaml_typing.Types.class_signature -> unit
val hide_private_methods : Ocaml_typing.Env.t -> Ocaml_typing.Types.class_signature -> unit
val close_class_signature : Ocaml_typing.Env.t -> Ocaml_typing.Types.class_signature -> bool
exception Nondep_cannot_erase of Ocaml_typing.Ident.t
val is_contractive : Ocaml_typing.Env.t -> Ocaml_typing.Path.t -> bool
val normalize_type : Ocaml_typing.Types.type_expr -> unit
val remove_mode_and_jkind_variables : Ocaml_typing.Types.type_expr -> unit
val nongen_vars_in_class_declaration : Ocaml_typing.Types.class_declaration -> Ocaml_typing.Btype.TypeSet.t option
type variable_kind =
  1. | Row_variable
  2. | Type_variable
type closed_class_failure = {
  1. free_variable : Ocaml_typing.Types.type_expr * Ocaml_typing.Ctype.variable_kind;
  2. meth : string;
  3. meth_ty : Ocaml_typing.Types.type_expr;
}
val free_non_row_variables_of_list : Ocaml_typing.Types.type_expr list -> Ocaml_typing.Types.type_expr list
val closed_type_expr : ?env:Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr -> bool
val closed_extension_constructor : Ocaml_typing.Types.extension_constructor -> Ocaml_typing.Types.type_expr option
val arity : Ocaml_typing.Types.type_expr -> int
val collapse_conj_params : Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr list -> unit
val get_current_level : unit -> int
val wrap_trace_gadt_instances : Ocaml_typing.Env.t -> ('a -> 'b) -> 'a -> 'b
type unwrapped_type_expr = {
  1. ty : Ocaml_typing.Types.type_expr;
  2. modality : Ocaml_typing.Mode.Modality.Const.t;
}
val type_jkind_purely_if_principal : Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr -> Ocaml_typing.Types.jkind_l option
val mk_jkind_context_check_principal : Ocaml_typing.Env.t -> Ocaml_typing.Jkind.jkind_context
val mk_jkind_context_always_principal : Ocaml_typing.Env.t -> Ocaml_typing.Jkind.jkind_context
val is_always_gc_ignorable : Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr -> bool
val check_and_update_generalized_ty_jkind : ?name:Ocaml_typing.Ident.t -> loc:Ocaml_parsing.Location.t -> Ocaml_typing.Env.t -> Ocaml_typing.Types.type_expr -> unit
val is_principal : Ocaml_typing.Types.type_expr -> bool
type global_state
val print_global_state : Stdlib.Format.formatter -> Ocaml_typing.Ctype.global_state -> unit

Get the crossing of a jkind

Get the crossing of a type wrapped in modalities. Non-principal types get trivial crossing.

Cross a right mode according to a type wrapped in modalities. Non-principal types don't cross.

Cross a left mode according to a type wrapped in modalities. Non-principal types don't cross.

Similar to cross_right but for Mode.Alloc

Similar to cross_left but for Mode.Alloc

Zap a modality to floor if the modes extension is enabled at a level more immature than the given one. Zap to id otherwise.

val mode_crossing_structure_memaddr : Ocaml_typing.Mode.Crossing.t

The mode crossing of the memory block of a structure.

val mode_crossing_functor : Ocaml_typing.Mode.Crossing.t

The mode crossing of a functor.

val mode_crossing_module : Ocaml_typing.Mode.Crossing.t

The mode crossing of any module.

Zap a modality to floor if maturity allows, zap to id otherwise.