Skip to content

Better mechanism of ordering global transformations #628

@davesnx

Description

@davesnx
Image

When users specify multiple global ppx transformations via preprocessors in a dune file, the order they apply is alphabetically by library name and described like this on the ppxlib documentation https://ocaml-ppx.github.io/ppxlib/ppxlib/driver.html#global-transfo-phase (Thanks for the ref @sim642)

This is problematic because ppx ordering is semantically significant: the output of one ppx often serves as input to another, and many ppxes don't commute. Using the name as a order is problematic since users can't change it (and they make authors responsible for the ppx name)

Current Behavior

Given this dune file:

(library
 (name mylib)
 (preprocess (pps ppx_jane ppx_deriving ppx_blob)))

Expected: ppxes are applied in the order written: ppx_janeppx_derivingppx_blob
Actual: Dune sorts them alphabetically and applies them as: ppx_blobppx_derivingppx_jane

Cross-reference: ocaml/dune#13551

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