Skip to content

PPX: add ppx_poly_constructor for errors

E. Rivas requested to merge er433/ppx/errors into dev

This MR uses a custom PPX to remove helper functions used in errors.ml.

Typically, we have a type declaration:

type Self_ast_imperative = [
  | `Self_ast_imperative_bad_set_param_type of (constant' * expression)
  ...
  | `Self_ast_imperative_no_shadowing of location
]

and then many defs. (one per constructor):

let bad_set_param_type c e = `Self_ast_imperative_bad_set_param_type (c,e)
...
let no_shadowing l = `Self_ast_imperative_no_shadowing l

Instead, we can derive defs. from the type declaration using poly_constructor:

type Self_ast_imperative = [
  | `Self_ast_imperative_bad_set_param_type of (constant' * expression)
  ...
  | `Self_ast_imperative_no_shadowing of location
] [@@deriving poly_constructor { prefix = "self_ast_imperative_" }]
  • has a changelog entry
Edited by E. Rivas

Merge request reports