ocaml-ppx / ppx_deriving

Type-driven code generation for OCaml
MIT License
464 stars 89 forks source link

README is a ambiguous as to current best practices for an end user #289

Open LAC-Tech opened 6 days ago

LAC-Tech commented 6 days ago

Hello,

The year is 2024, and I want to pretty print my own ocaml record type.

Is the text in the readme saying I should be using Ppxlib.Deriving for that use case?

Or is this library still recommended for the end user?

sim642 commented 6 days ago

I guess this is about this note in the README:

Note: since deriving was released by whitequark in 2014, the OCaml ppx ecosystem has changed a lot. For new projects wishing to create a new deriving plugin, we recommend using ppxlib directly. The module Ppxlib.Deriving provide functionality similar to deriving, better integrated with ppxlib, and offers a nicer API in some places. deriving is still maintained to keep existing plugins working as well as possible. Although note that the above deprecation note only covers the API and not the plugins (e.g. ppx_deriving.show, ppx_deriving.eq, ...).

The derivers like show in ppx_deriving are still in good shape.

What the note warns about is writing new derivers: they should be written using ppxlib APIs, not ppx_deriving's old APIs. The ppx_deriving plugins themselves have also been ported now in #263, so they follow that advice.

Ppxlib itself does not provide any such plugins, it's just the API.

LAC-Tech commented 5 days ago

Yes, that comment is a rollercoaster.

Note: since deriving was released by whitequark in 2014, the OCaml ppx ecosystem has changed a lot.

Ok, so ppx_deriving is legacy.

For new projects wishing to create a new deriving plugin, we recommend using ppxlib directly.

Ah but I am not wishing to do that, so nevermind.

The module Ppxlib.Deriving provide functionality similar to deriving, better integrated with ppxlib, and offers a nicer API in some places. deriving is still maintained to keep existing plugins working as well as possible.

Wait so this newer library does the same thing as this module, and this module is only maintained for legacy reasons?

Just make it really cut and dry:

Note: For projects wishing to create new deriving plugins, use ppxlib directly.