Skip to content

Unclear update path for Ast_pattern.pexp_function in 0.36 #615

@tobil4sk

Description

@tobil4sk

ppx_parser has a pattern that uses Ast_pattern.pexp_function from ppxlib 0.35 and below:

https://github.com/NielsMommen/ppx_parser/blob/c1d8f379a05ddfd55306f58ed643066b07549b3f/rewriter/ppx_parser.ml#L3-L7

let ppx_parser_pat = Ast_pattern.(single_expr_payload
  (alt
    (pexp_function __ |> map1 ~f:(fun cases -> (None, cases)) )
    (pexp_match __ __ |> map2 ~f:(fun e cases -> (Some e, cases)) ))
  )

However, in ppxlib 0.36 and above, the signature has changed and this no longer compiles.

In the migration guide: https://github.com/ocaml-ppx/ppxlib/wiki/Upgrading-to-ppxlib-0.36.0:

Since Pexp_function now represents all functions and not just the special pattern-matching case, pexp_function now builds full functions and not just ones with cases. When upgrading, your easiest path is to replace your calls to pexp_function with calls to pexp_function_cases.

This is for Ast_builder. There is no equivalent Ast_pattern.pexp_function_cases, is this intentional or an oversight?

From the documentation: https://ocaml.org/p/ppxlib/0.37.0/doc/matching-code.html#building-patterns

All constructors from Ast_builder have a "deconstructor" in Ast_pattern with the same name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions