Ocaml_typing.Ctype
Sourceval flatten_fields :
Types.type_expr ->
(string * Types.field_kind * Types.type_expr) list * 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 associate_fields :
(string * Types.field_kind * Types.type_expr) list ->
(string * Types.field_kind * Types.type_expr) list ->
(string
* Types.field_kind
* Types.type_expr
* Types.field_kind
* Types.type_expr)
list
* (string * Types.field_kind * Types.type_expr) list
* (string * Types.field_kind * Types.type_expr) list
val sort_row_fields :
(Ocaml_parsing.Asttypes.label * Types.row_field) list ->
(Ocaml_parsing.Asttypes.label * Types.row_field) list
val merge_row_fields :
(Ocaml_parsing.Asttypes.label * Types.row_field) list ->
(Ocaml_parsing.Asttypes.label * Types.row_field) list ->
(Ocaml_parsing.Asttypes.label * Types.row_field) list
* (Ocaml_parsing.Asttypes.label * Types.row_field) list
* (Ocaml_parsing.Asttypes.label * Types.row_field * Types.row_field) list
val filter_row_fields :
bool ->
(Ocaml_parsing.Asttypes.label * Types.row_field) list ->
(Ocaml_parsing.Asttypes.label * Types.row_field) list
val new_local_type :
?loc:Ocaml_parsing.Location.t ->
?manifest_and_scope:(Types.type_expr * int) ->
unit ->
Types.type_declaration
val instance_constructor :
existential_treatment ->
Types.constructor_description ->
Types.type_expr list * Types.type_expr * Types.type_expr list
val instance_parameterized_type :
?keep_names:bool ->
Types.type_expr list ->
Types.type_expr ->
Types.type_expr list * Types.type_expr
val instance_class :
Types.type_expr list ->
Types.class_type ->
Types.type_expr list * Types.class_type
val instance_poly :
?keep_names:bool ->
bool ->
Types.type_expr list ->
Types.type_expr ->
Types.type_expr list * Types.type_expr
val instance_label :
bool ->
Types.label_description ->
Types.type_expr list * Types.type_expr * Types.type_expr
val apply :
?use_current_level:bool ->
Env.t ->
Types.type_expr list ->
Types.type_expr ->
Types.type_expr list ->
Types.type_expr
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.
val expanded_diff :
Env.t ->
got:Types.type_expr ->
expected:Types.type_expr ->
(Errortrace.expanded_type, 'variant) Errortrace.elt
Create an Errortrace.Diff
by expanding the two types
val unexpanded_diff :
got:Types.type_expr ->
expected:Types.type_expr ->
(Errortrace.expanded_type, 'variant) Errortrace.elt
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_type
s.
type typedecl_extraction_result =
| Typedecl of Path.t * Path.t * Types.type_declaration
| Has_no_typedecl
| May_have_typedecl
val unify_gadt :
equations_level:int ->
allow_recursive_equations:bool ->
Env.t ref ->
Types.type_expr ->
Types.type_expr ->
Btype.TypePairs.t
val filter_arrow :
Env.t ->
Types.type_expr ->
Ocaml_parsing.Asttypes.arg_label ->
Types.type_expr * Types.type_expr
type filter_arrow_failure =
| Unification_error of Errortrace.unification_error
| Label_mismatch of {
got : Ocaml_parsing.Asttypes.arg_label;
expected : Ocaml_parsing.Asttypes.arg_label;
expected_type : Types.type_expr;
}
| Not_a_function
type filter_method_failure =
| Unification_error of Errortrace.unification_error
| Not_a_method
| Not_an_object of Types.type_expr
type class_match_failure =
| CM_Virtual_class
| CM_Parameter_arity_mismatch of int * int
| CM_Type_parameter_mismatch of Env.t * Errortrace.equality_error
| CM_Class_type_mismatch of Env.t * Types.class_type * Types.class_type
| CM_Parameter_mismatch of Env.t * Errortrace.moregen_error
| CM_Val_type_mismatch of string * Env.t * Errortrace.comparison_error
| CM_Meth_type_mismatch of string * Env.t * Errortrace.comparison_error
| CM_Non_mutable_value of string
| CM_Non_concrete_value of string
| CM_Missing_value of string
| CM_Missing_method of string
| CM_Hide_public of string
| CM_Hide_virtual of string * string
| CM_Public_method of string
| CM_Private_method of string
| CM_Virtual_method of string
val match_class_types :
?trace:bool ->
Env.t ->
Types.class_type ->
Types.class_type ->
class_match_failure list
val equal_private :
Env.t ->
Types.type_expr list ->
Types.type_expr ->
Types.type_expr list ->
Types.type_expr ->
unit
val match_class_declarations :
Env.t ->
Types.type_expr list ->
Types.class_type ->
Types.type_expr list ->
Types.class_type ->
class_match_failure list
val add_method :
Env.t ->
Ocaml_parsing.Asttypes.label ->
Ocaml_parsing.Asttypes.private_flag ->
Ocaml_parsing.Asttypes.virtual_flag ->
Types.type_expr ->
Types.class_signature ->
unit
type add_instance_variable_failure =
| Mutability_mismatch of Ocaml_parsing.Asttypes.mutable_flag
| Type_mismatch of Errortrace.unification_error
val add_instance_variable :
strict:bool ->
Env.t ->
Ocaml_parsing.Asttypes.label ->
Ocaml_parsing.Asttypes.mutable_flag ->
Ocaml_parsing.Asttypes.virtual_flag ->
Types.type_expr ->
Types.class_signature ->
unit
type inherit_class_signature_failure =
| Self_type_mismatch of Errortrace.unification_error
| Method of Ocaml_parsing.Asttypes.label * add_method_failure
| Instance_variable of Ocaml_parsing.Asttypes.label
* add_instance_variable_failure
val inherit_class_signature :
strict:bool ->
Env.t ->
Types.class_signature ->
Types.class_signature ->
unit
val update_class_signature :
Env.t ->
Types.class_signature ->
Ocaml_parsing.Asttypes.label list * Ocaml_parsing.Asttypes.label list
val nondep_type_decl :
Env.t ->
Ident.t list ->
bool ->
Types.type_declaration ->
Types.type_declaration
val nondep_extension_constructor :
Env.t ->
Ident.t list ->
Types.extension_constructor ->
Types.extension_constructor
val nondep_class_declaration :
Env.t ->
Ident.t list ->
Types.class_declaration ->
Types.class_declaration
val nondep_cltype_declaration :
Env.t ->
Ident.t list ->
Types.class_type_declaration ->
Types.class_type_declaration
type closed_class_failure = {
free_variable : Types.type_expr * variable_kind;
meth : string;
meth_ty : Types.type_expr;
}
val closed_class :
Types.type_expr list ->
Types.class_signature ->
closed_class_failure option
val package_subtype :
(Env.t ->
Path.t ->
(Ocaml_parsing.Longident.t * Types.type_expr) list ->
Path.t ->
(Ocaml_parsing.Longident.t * Types.type_expr) list ->
bool)
ref