ocaml-base-compiler

Official release 4.14.0
Legend:
Library
Module
Module type
Parameter
Class
Class type
Library ocamlcommon
Module Errortrace
type position =
| First
| Second
val swap_position : position -> position
val print_pos : Format.formatter -> position -> unit
type expanded_type = {
ty : Types.type_expr;
expanded : Types.type_expr;
}
val trivial_expansion : Types.type_expr -> expanded_type

trivial_expansion ty creates an expanded_type whose expansion is also ty. Usually, you want Ctype.expand_type instead, since the expansion carries useful information; however, in certain circumstances, the error is about the expansion of the type, meaning that actually performing the expansion produces more confusing or inaccurate output.

type 'a diff = {
got : 'a;
expected : 'a;
}
val map_diff : ( 'a -> 'b ) -> 'a diff -> 'b diff

map_diff f {expected;got} is {expected=f expected; got=f got}

type 'a escape_kind =
| Constructor of Path.t
| Univ of Types.type_expr
| Self
| Module_type of Path.t
| Equation of 'a
| Constraint

Scope escape related errors

type 'a escape = {
kind : 'a escape_kind;
context : Types.type_expr option;
}
val map_escape : ( 'a -> 'b ) -> 'a escape -> 'b escape
val explain : 'a list -> ( prev:'a option -> 'a -> 'b option ) -> 'b option
type unification = private
| Unification

Type indices

type comparison = private
| Comparison
type fixed_row_case =
| Cannot_be_closed
| Cannot_add_tags of string list
type 'variety variant =
| Incompatible_types_for : string -> _ variant
| No_tags : position * (Asttypes.label * Types.row_field) list -> _ variant
| No_intersection : unification variant
| Fixed_row : position * fixed_row_case * Types.fixed_explanation -> unification variant
| Presence_not_guaranteed_for : position * string -> comparison variant
| Openness : position -> comparison variant
type 'variety obj =
| Missing_field : position * string -> _ obj
| Abstract_row : position -> _ obj
| Self_cannot_be_closed : unification obj
type ('a, 'variety) elt =
| Diff : 'a diff -> ( 'a, _ ) elt
| Variant : 'variety variant -> ( 'a, 'variety ) elt
| Obj : 'variety obj -> ( 'a, 'variety ) elt
| Escape : 'a escape -> ( 'a, _ ) elt
| Incompatible_fields : {
name : string;
diff : Types.type_expr diff;
} -> ( 'a, _ ) elt
| Rec_occur : Types.type_expr * Types.type_expr -> ( 'a, _ ) elt
type ('a, 'variety) t = ( 'a, 'variety ) elt list
type 'variety trace = ( Types.type_expr, 'variety ) t
type 'variety error = ( expanded_type, 'variety ) t
val map : ( 'a -> 'b ) -> ( 'a, 'variety ) t -> ( 'b, 'variety ) t
val incompatible_fields : name:string -> got:Types.type_expr -> expected:Types.type_expr -> ( Types.type_expr, _ ) elt
val swap_trace : ( 'a, 'variety ) t -> ( 'a, 'variety ) t

The traces ('variety t) are the core error types. However, we bundle them up into three "top-level" error types, which are used elsewhere: unification_error, equality_error, and moregen_error. In the case of equality_error, this has to bundle in extra information; in general, it distinguishes the three types of errors and allows us to distinguish traces that are being built (or processed) from those that are complete and have become the final error. These error types have the invariants that their traces are nonempty; we ensure that through three smart constructors with matching names.

type unification_error = private {
trace : unification error;
}
type equality_error = private {
trace : comparison error;
subst : (Types.type_expr * Types.type_expr) list;
}
type moregen_error = private {
trace : comparison error;
}
val unification_error : trace:unification error -> unification_error
val equality_error : trace:comparison error -> subst:(Types.type_expr * Types.type_expr) list -> equality_error
val moregen_error : trace:comparison error -> moregen_error
type comparison_error =
| Equality_error of equality_error
| Moregen_error of moregen_error

Wraps up the two different kinds of comparison errors in one type

val swap_unification_error : unification_error -> unification_error

Lift swap_trace to unification_error

module Subtype : sig ... end