jon.recoil.org

Module Errortrace

type position =
  1. | First
  2. | Second
val print_pos : Stdlib.Format.formatter -> Errortrace.position -> unit
type expanded_type = {
  1. ty : Types.type_expr;
  2. expanded : Types.type_expr;
}
val trivial_expansion : Types.type_expr -> Errortrace.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 = {
  1. got : 'a;
  2. expected : 'a;
}
val map_diff : ('a -> 'b) -> 'a Errortrace.diff -> 'b Errortrace.diff

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

type 'a escape_kind =
  1. | Constructor of Path.t
  2. | Univ of Types.type_expr
  3. | Self
  4. | Module_type of Path.t
  5. | Equation of 'a
  6. | Constraint

Scope escape related errors

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

Type indices

type comparison = private
  1. | Comparison
type fixed_row_case =
  1. | Cannot_be_closed
  2. | Cannot_add_tags of string list
type 'variety obj =
  1. | Missing_field : Errortrace.position * string -> _ Errortrace.obj
  2. | Abstract_row : Errortrace.position -> _ Errortrace.obj
  3. | Self_cannot_be_closed : Errortrace.unification Errortrace.obj
type ('a, 'variety) elt =
  1. | Diff : 'a Errortrace.diff -> ('a, _) Errortrace.elt
  2. | Variant : 'variety Errortrace.variant -> ('a, 'variety) Errortrace.elt
  3. | Obj : 'variety Errortrace.obj -> ('a, 'variety) Errortrace.elt
  4. | Escape : 'a Errortrace.escape -> ('a, _) Errortrace.elt
  5. | Incompatible_fields : {
    1. name : string;
    2. diff : Types.type_expr Errortrace.diff;
    } -> ('a, _) Errortrace.elt
  6. | Rec_occur : Types.type_expr * Types.type_expr -> ('a, _) Errortrace.elt
  7. | Bad_jkind : Types.type_expr * Jkind.Violation.t -> ('a, _) Errortrace.elt
  8. | Bad_jkind_sort : Types.type_expr * Jkind.Violation.t -> ('a, _) Errortrace.elt
  9. | Unequal_var_jkinds : Types.type_expr * Types.jkind_lr * Types.type_expr * Types.jkind_lr -> ('a, _) Errortrace.elt
  10. | Unequal_tof_kind_jkinds : Types.jkind_lr * Types.jkind_lr -> ('a, _) Errortrace.elt
type ('a, 'variety) t = ('a, 'variety) Errortrace.elt list
type 'variety trace = (Types.type_expr, 'variety) Errortrace.t
type 'variety error = (Errortrace.expanded_type, 'variety) Errortrace.t
val map : ('a -> 'b) -> ('a, 'variety) Errortrace.t -> ('b, 'variety) Errortrace.t
val incompatible_fields : name:string -> got:Types.type_expr -> expected:Types.type_expr -> (Types.type_expr, _) Errortrace.elt
val swap_trace : ('a, 'variety) Errortrace.t -> ('a, 'variety) Errortrace.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 {
  1. trace : Errortrace.unification Errortrace.error;
}
type equality_error = private {
  1. trace : Errortrace.comparison Errortrace.error;
  2. subst : (Types.type_expr * Types.type_expr) list;
}
type moregen_error = private {
  1. trace : Errortrace.comparison Errortrace.error;
}
type comparison_error =
  1. | Equality_error of Errortrace.equality_error
  2. | Moregen_error of Errortrace.moregen_error

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

Lift swap_trace to unification_error

module Subtype : sig ... end