package ocaml-base-compiler

  1. Overview
  2. Docs

Unification traces are used to explain unification errors when printing error messages

type position =
  1. | First
  2. | Second
type desc = {
  1. t : Types.type_expr;
  2. expanded : Types.type_expr option;
}
type 'a diff = {
  1. got : 'a;
  2. expected : 'a;
}
type 'a escape =
  1. | Constructor of Path.t
  2. | Univ of Types.type_expr
    (*

    The type_expr argument of Univ is always a Tunivar _, we keep a type_expr to track renaming in Printtyp

    *)
  3. | Self
  4. | Module_type of Path.t
  5. | Equation of 'a

Scope escape related errors

Errors for polymorphic variants

type fixed_row_case =
  1. | Cannot_be_closed
  2. | Cannot_add_tags of string list
type variant =
  1. | No_intersection
  2. | No_tags of position * (Asttypes.label * Types.row_field) list
  3. | Incompatible_types_for of string
  4. | Fixed_row of position * fixed_row_case * Types.fixed_explanation
    (*

    Fixed row types, e.g. 'a. [> `X] as 'a

    *)
type obj =
  1. | Missing_field of position * string
  2. | Abstract_row of position
  3. | Self_cannot_be_closed
type 'a elt =
  1. | Diff of 'a diff
  2. | Variant of variant
  3. | Obj of obj
  4. | Escape of {
    1. context : Types.type_expr option;
    2. kind : 'a escape;
    }
  5. | Incompatible_fields of {
    1. name : string;
    2. diff : Types.type_expr diff;
    }
  6. | Rec_occur of Types.type_expr * Types.type_expr
type t = desc elt list
val map_diff : ('a -> 'b) -> 'a diff -> 'b diff

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

val flatten : (Types.type_expr -> Types.type_expr -> 'a) -> t -> 'a elt list

flatten f trace flattens all elements of type desc in trace to either f x.t expanded if x.expanded=Some expanded or f x.t x.t otherwise

val swap : t -> t

Switch expected and got

val explain : 'a elt list -> (prev:'a elt option -> 'a elt -> 'b option) -> 'b option

explain trace f calls f on trace elements starting from the end until f ~prev elt is Some _, returns that or None if the end of the trace is reached.

OCaml

Innovation. Community. Security.