package ppxlib_jane

  1. Overview
  2. Docs

Module Ppxlib_jane.Legacy_pexp_functionSource

Use of this module is discouraged.

This module allows you to turn matches on Pexp_function (params, constraint_, body) into matches on the old parsetree prior to OCaml 5.2:

  • Pexp_newtype (newtype, body)
  • Pexp_fun (label, default, pat)
  • Pexp_function cases

These constructors are available below, but with Legacy_ tacked onto the name.

Generally, ppx authors should prefer handling the new Pexp_function constructor directly. This module was introduced to make it easier to update old ppxes, but it has less obvious behavior and is kludgy.

type legacy_pexp_function := Ppxlib_ast.Parsetree.case list
type legacy_pexp_newtype := string Ppxlib_ast.Asttypes.loc * Ppxlib_ast.Parsetree.expression
Sourcetype t =
  1. | Legacy_pexp_fun of legacy_pexp_fun
    (*

    Match Pexp_fun, as in the OCaml parsetree prior to 5.2. To construct, use Ppxlib.Ast_builder.Default.pexp_fun.

    *)
  2. | Legacy_pexp_function of legacy_pexp_function
    (*

    Match Pexp_function, as in the OCaml parsetree prior to 5.2. To construct, use Ppxlib.Ast_builder.Default.pexp_function.

    *)
  3. | Legacy_pexp_newtype of legacy_pexp_newtype

Creation functions

Sourceval of_parsetree : Ppxlib_ast.Parsetree.expression_desc -> t option

Testing a particular constructor of t.

Sourceval legacy_pexp_fun_of_parsetree : Ppxlib_ast.Parsetree.expression_desc -> legacy_pexp_fun option
Sourceval legacy_pexp_function_of_parsetree : Ppxlib_ast.Parsetree.expression_desc -> legacy_pexp_function option
Sourceval legacy_pexp_newtype_of_parsetree : Ppxlib_ast.Parsetree.expression_desc -> legacy_pexp_newtype option