We're happy to announce the release of Ppxlib 0.36.1!
See full changelog
- Fix ppxlib driver's AST to source printer. Our copy of pprintast was not properly updated which resulted in incorrect printing of value bindings' constraints (#585, @NathanReb)
Read the latest releases and updates from the OCaml compiler, OCaml infrastructure and the OCaml Platform Tools.
We're happy to announce the release of Ppxlib 0.36.1!
We are happy to announce the release of ppxlib.0.36.0!
With this release, the internal AST that ppxlib targets has been bumped to the AST of OCaml 5.2. Ppx authors can now use features from OCaml 5.2. Ppxlib still supports any OCaml compiler after and including 4.08.0.
Many ppxes will be broken by changes made to the representation of functions. Authors are encouraged to read the upgrade guide.
Change Location.none to match the compiler's Location.none as of OCaml
4.08. This fixes a bug in loc_of_attribute (#540, @ncik-roberts, @patricoferris)
Bump ppxlib's AST to 5.2.0 (#514, @patricoferris)
Add the [@@@expand_inline] transformation and support for floating attribute context
free transformations. (#560, @jaymody)
Add a -raise-embedded-errors flag to the driver. Setting this flag raises the first
ocaml.error embedded in the final AST.
Export Ast_pattern.fail. (#563, @ceastlund)
Make Ast_traverse.sexp_of more concise, and add a test. (#561, @ceastlund)
We are happy to announce the release of ppxlib.0.35.0!
The main feature of this release is improved support for OCaml 5.3, allowing ppx users to have ppx rewriters operate on files with the new effect syntax.
Note that ppx-es and the effect syntax can cohabit but it is possible that ppx rewriters will error out if they encounter effect syntax node in their extension's payload or in the items they generate code from.
This feature also comes with a new --use-compiler-pp driver flag. This flag is required to preserve the effect syntax when the ppxlib driver outputs source code instead of marshalled AST. Note that the vast majority of users won't need to use this flag but it can come in handy in some more advanced use cases.
Allow use of effect syntax in preprocessed files without causing migration failures. (#552, @hhugo, @NathanReb)
Remove support for compilers older than 4.08 (#556, @NathanReb)
Add a --use-compiler-pp flag to the standalone driver. This flag
can be set when the driver outputs source code to make it use the compiler's
Pprintast instead of ppxlib's.
(#555, @NathanReb)
We’re happy to announce that we just released ppxlib.0.34.0.
The full patch notes are available on the release page over here.
The main features are OCaml 5.3 compatibility, new AST pretty-printing utilities and the ppxlib-tools package, support for [@@deriving ...] on class types and the addition of missing Pprintast entry points.
ppxlib.0.34.0 is the first official ppxlib release that’s compatible with the new 5.3 compiler.
The ppxlib driver now also comes with a -keywords CLI option, similar to the compiler’s that allow you to compile and preprocess with the 5.3 compiler code that uses effect as an identifier. This is pretty niche but it’s there should you need it.
Please note that means you can use ppx-es with a 5.3 compiler but not that ppx-es can consume/produce 5.3 language features. We’re currently working on a fix allowing you to use the effect syntax in files that require preprocessing as it’s not possible with 0.34.0. The fix should be released in the next few days as 0.34.1.
We added a new Pp_ast module that allows you to pretty print AST fragments.
The only way ppxlib would print ASTs before were as S-expressions. In practice we found that it was not always helpful and wanted a more readable and human friendly way of displaying the AST.
The default output of those printer is a simplified version of the AST to keep things clear and avoid cluttering the output with information that is not always useful. For example, if you run Ppxlib.Pp_ast.Default.expression on the AST for x + 2, you’ll get the following:
Pexp_apply
( Pexp_ident (Lident "+")
, [ ( Nolabel, Pexp_ident (Lident "x"))
; ( Nolabel, Pexp_constant (Pconst_integer ( "2", None)))
]
)
The alert reader will note that there are no locations or attributes and that the expression record layer is omitted here.
You can of course configure the printer to display more information if you need to.
We’ve been using these new printers internally to debug migration code and they have been a huge help so we hope they will make working with ppxlib easier for you too.
In addition to this new module, we also added a command line utility called ppxlib-pp-ast to pretty print ASTs from source files, source code fragments or even marshalled AST files. It is very similar to the old ppx_tools’s dumpast.
Note that it will print ppxlib’s internal AST after it’s been migrated from the installed compiler’s version. This is something that we could not simply achieve with OCaml’s own -dparsetree.
This should be a useful tool for debugging ppx related bugs or learning about the AST and we hope ppx authors and users will like it.
As mentioned above, we also added some missing Pprintast* entries such as binding, longident and payload.
It is now possible to use [@@deriving ...] on class type declarations and therefore to write derivers for class types.
*: To the confused readers: Pprintast is entirely different from Pp_ast mentioned above as it prints the source code corresponding to a given AST.
We wanted to thank our external contributors for this release: @hhugo, @nojb and @dra27 for their help on the 5.3 compat and @mattiasdrp for bringing the Pprintast module up to speed.
Special thanks as well to @pedrobslisboa who started integrating their excellent ppx-by-example into ppxlib’s documentation.
Finally, I’d also like to thank the OCaml Software Foundation who’s been funding all my work on ppxlib and made this release possible!
Happy preprocessing to you all!
Add initial OCaml 5.3 support (#487, @NathanReb, @hhugo, @nojb)
Initialise OCaml 5.3's lexer with the keywords setting from OCAMLPARAM or
the new -keywords driver's CLI option to allow the standalone ppx driver to
process old packages using effect as an identifier
(#535, @dra27, @NathanReb)
Add Pprintast.binding, longident and payload (#542, @mattiasdrp)
Fix deriving_inline round-trip check so that it works with 5.01 <-> 5.02
migrations (#519, @NathanReb)
Add ppxlib's AST pretty-printing utilities in Ppxlib.Pp_ast and
a ppxlib-pp-ast executable in a new separate ppxlib-tools package
(#517, #525, #537, @NathanReb)
Change -dparsetree from a sexp output to a pretty printed AST, closer
to what the compiler's -dparsetree is.
(#530, @NathanReb)
Add Parsetree documentation comments to Ast_builder functions (#518, @patricoferris)
Support class type declarations in derivers with the new, optional arguments
{str,sig}_class_type_decl in Deriving.add (#538, @patricoferris)
The Ppxlib dev team is happy to announce the release of ppxlib.0.33.0.
This release's main feature is a series of improvement to flags controlling
unused value/module/type warnings silencing.
The ppxlib driver generates warning silencing items to prevent [@@deriving ...]
generated code to trigger unused code warnings. Three warnings are disabled that
way:
[@@deriving ...] attribute is attached.
This feature was added a long time ago to avoid manually disabling those
warnings when working with derivers that generate a set of values and modules
only to use a subset of those. Alternatively, the unused type warning silencing
was added to allow defining an alias type only to be consumed by a deriver (e.g.,
type error = [`Not_found | `Invalid_arg] [@@deriving to_string]).
We since then believe that we should not disable warnings lightly, as this
behaviour makes it difficult to find and remove deadcode. The right approach in
those situations should be to fix the PPX derivers so that they are more
configurable and can be used without triggering such warnings.
We will start to move toward removing this feature, but since it is still useful in
some places, we came up with a plan to do this iteratively.
In ppxlib.0.31.0 we added the -unused-code-warnings driver flag and the
?unused_code_warnings Deriving.V2.make optional argument to control whether
to silence Warnings 32 and 60. When both are set to true, by the user and the
deriver authors, the warnings are not silenced. As of ppxlib.0.33.0, these also
control the silencing of Warning 34 (unused type).
force can now be passed to the -unused-code-warnings flag in order to
disable warnings silencing, regardless of the derivers opting in. This allows
users to test whether their codebase and their set of derivers rely on warning
silencing or not and to use those results to eliminate deadcode and/or report
issues upstream to the derivers they use.
We also added a separate -unused-type-warnings flag that works similarly to
-unused-code-warnings (i.e., depends on the value of the
?unused_code_warnings argument), but it only controls Warning 34 silencing, as it
turns out it is less likely to cause unwanted warnings than with the other two.
This will allow users to disable it more easily, without having to deal with
Warnings 32 and 60 straight away.
We want to encourage users to try those on their codebase in order to see the impact
it has. Did you have deadcode lying around that slipped past undetected? Does
this trigger unwanted warnings because of deriver's generated code?
The plan is to give the ecosystem some time to try those features and adapt by fixing
individual derivers and flipping setting ?unused_code_warnings to true as they
do. After a while, we will swap the default value of the driver flag to true so
that only derivers that haven't opted in will enable warning silencing. Then as
time goes we will swap the default of the Deriving.make argument so that
derivers will instead have to explicitly opt out to get the warning silencing.
Finally, once we are confident the ecosystem is in a good enough state, we will
remove this feature altogether.ppxlib.0.33.0 also comes with a couple of new features for PPX authors:
Ast_builder functions: elist_tail and plist_tail
that can be used to build list expressions and patterns with a custom tail:
elist_tail [expr1; expr2] tail_expr returns the expression for
expr1::expr2::tail_expr.Context_free.special_function', a new version of special_function that
allows passing a Longident.t directly rather that relying on parsing the
string argument to a Longident.t.Finally, the release includes a few bug fixes to Longident.parse and
Code_path.main_module_name and fixes the location-check flag so it is not
required to also pass -check to enable location checks. It also fixes the 5.2
migrations locations, as we used to build nodes with inconsistent locations when
migrating Pexp_function nodes.
We would like to thank our external contributors who have been a huge part of this release: @octachron, @vg-b, and @jchavarri, and a special mention to @mbarbin, who has not only contributed a lot to the warning silencing features but has been extensively testing and providing very useful feedback on them.
And of course, as usual, we'd like to thank the OCaml Software Foundation who has been funding my work on Ppxlib and on this release, making all of this possible!
Fix a bug where Code_path.main_module_name would not properly remove
extensions from the filename and therefore return an invalid module name.
(#512, @NathanReb)
Add -unused-type-warnings flag to the driver to allow users to disable
only the generation of Warning 34 silencing structure items when using
[@@deriving ...] on type declarations. (#511, @mbarbin, @NathanReb)
Make the -unused-code-warnings driver flag also control Warning 34
silencing for type declarations with [@@deriving ...] attached.
(#510, @mbarbin, @NathanReb)
Add -unused-code-warnings=force driver command-line flag argument. (#490, @mbarbin)
Add new functions Ast_builder.{e,p}list_tail that take an extra tail
expression/pattern argument parameter compared to Ast_builder.{e,p}list, so
they can build ASTs like a :: b :: c instead of only [ a; b ].
(#498, #502, @v-gb, @NathanReb)
Fix Longident.parse so it also handles indexing operators such as
.!(), .%(;..)<-, or Vec.(.%()) (#494, @octachron)
Add a special_function' variant that directly takes a Longident.t
argument in order to avoid the issue with Longident.t covering distinct
syntactic classes that cannot be easily parsed by a common parser (#496, @octachron).
Keep location ranges consistent when migrating Pexp_function nodes from 5.2+
to older versions (#504, @jchavarri)
Fix -locations-check behaviour so it is no longer required to pass -check and
can enable location checks. (#506, @NathanReb)
The ppxlib team is happy to announce the release of ppxlib.0.32.1.
The main feature of this release is of course the support for the upcoming OCaml 5.2 release. Starting with this version you'll be able to use ppx with the latest compiler.
The feature also comes with a small follow up improvement to the 0.32.0 error reporting changes that simplifies how exception thrown from context free rewriting are handled. The errors will now be inserted where the generated code would have been instead of appended to the whole AST. This should lead to a better error reporting from the compiler as it will now report errors in order of their position in the code.
We'd like to thank the OCaml Software Foundation once again as they funded the vast majority of the work for this release.
Add support for OCaml 5.2
Insert errors from caught located exceptions in place of the code that should have been generated by context-free rules. (#472, @NathanReb)
The ppxlib dev team is happy to announce the release of ppxlib.0.32.0.
The main feature of this release, implemented by @burnleydev1 during their Outreachy internship, is a huge improvement of the handling of located exceptions raised by ppx-es. Whenever a rewrite of the AST throws such an exception, the ppxlib driver catches it and resumes the rewriting using the latest valid AST it knows of. All caught exceptions are appended to the final AST as [%%ocaml.error ..] nodes. This means the driver returns a valid AST instead of one composed of a single error node corresponding to the first raised exception.
This leads to a much better experience for ppx users as merlin now has a valid AST to work with when this happens, allowing it to properly function, reporting all errors, from ppx-es or otherwise.
Note that despite this change we still recommend ppx authors to embed errors in the rewritten AST rather than throw exceptions.
The release also comes with a few bug fixes on longident parsing or windows compatibility and a new simplified API for ppx authors using attributes as flags (i.e. attributes without payloads such as [@ignore] for instance).
We'd like to thank our external contributors for this release:
We'd also like to thank the OCaml Software Foundation who has been funding my work on this release.
Add an optional embed_errors argument to Context_free.map_top_down that
controls how to deal with exceptions thrown by context-free rules.
(#468, @NathanReb)
Fix Longident.parse so it properly handles unparenthesized dotted operators
such as +. or *.. (#111, @rgrinberg, @NathanReb)
raising an exception does no longer cancel the whole context free phase(#453, @burnleydev1)
Sort embedded errors that are appended to the AST by location so the compiler reports the one closer to the beginning of the file first. (#463, @NathanReb)
Update Attribute.get to ignore loc_ghost. (#460, @ceastlund)
Add API to manipulate attributes that are used as flags (#408, @dianaoigo)
Update changelog to use ISO 8061 date format: YYYY-MM-DD. (#445, @ceastlund)
Replace Caml with Stdlib. (#427, @ceastlund)
When a transformation raises, the last valid AST is used as input to the upcoming transformations. All such errors are collected and appended as extension nodes to the final AST (#447, @burnleydev1)
Fix a small mistake in the man pages: Embededding errors is done by default with
-as-pp, not with -dump-ast (#464, @pitag-ha)
Set appropriate binary mode when writing to stdout especially for Windows
compatibility. (#466, @jonahbeckford)
We're happy to announce the release of Ppxlib 0.31.0. Shortly after OCaml 5.1.0 has been released,
this Ppxlib release fixes a bug in the support of OCaml 5.1.0. Before that bug fix, the warnings about a generative/applicative mismatch between a functor creation and its application introduced by OCaml 5.1.0 were also triggered when that mismatch didn't exist.
Furthermore, the release contains a couple of bug fixes in the context of attributes.
We're also excited about two main enhancements. One allows authors of extension node rewriters to add a path argument to the extension node. That's excellent for hygiene since it allows the PPX to be explicit about modules rather than depending on its scope.
The other main enhancement allows an opt-in for compiler warnings about unused code generated by derivers (warnings w32 and w60). That opting in needs to happen on both sides of the deriver, the writer side and the user side. Opting in to those code warnings will help to clean up unused code, leading to performance improvements in compilation and editor support.
Fix support for OCaml 5.1: migrated code preserves generative functor warnings, without creating more. Locations are better preserved. (#432, @pitag-ha, @panglesd)
Driver: Add -unused-code-warnings command-line flag. (#444, @ceastlund)
Add ?warning flag to Deriving.Generator.make. (#440, @jacksonzou123 via @ceastlund)
Restore the path_arg functionality in the V3 API. (#431, @ELLIOTTCABLE)
Expose migration/copying/etc. functions for all AST types needed by Pprintast. (#454, @antalsz)
Preserve quoted attributes on antiquotes in metaquot. (#441, @ncik-roberts)
Attribute namespaces: Fix semantics of reserving multi-component namespaces. (#443, @ncik-roberts)
We're excited to announce the release of Ppxlib 0.30.0! It comes with support for OCaml 5.1, various enhancements, and bug fixes.
For PPX writing, Ast_pattern now offers additional utility functions, while metaquot benefits from improved error reporting.
PPX usage sees better compatibility with OCaml trunk, thanks to the Driver's improved Parsetree version recognition. This allows for compatibility with both trunk and stable OCaml versions concurrently.
Finally, this release enhances Ppxlib's compatibility with ReScript, introducing "ns" and "res" as reserved namespaces.
Ast_pattern now has ebool, pbool helper, and a new map.(ocaml-ppx/ppxlib#402, @Burnleydev1)metaquot. (ocaml-ppx/ppxlib#397, @Burnleydev1)Attribute.declare_with_attr_loc (ocaml-ppx/ppxlib#396, @dvulakh)Quoter's let binding non-recursive (ocaml-ppx/ppxlib#401, @sim642)Parsetree magic numbers to Parsetree versions towards the current version,
as it is usually the common case and it helps when magic numbers are
ambiguous (such as on development versions) (ocaml-ppx/ppxlib#409, @shym)base and stdio (ocaml-ppx/ppxlib#421, @kit-ty-kate)ppxlib contains more than a library
(Update the opam description ocaml-ppx/ppxlib#422, @pitag-ha)5.1.0~alpha1 (ocaml-ppx/ppxlib#428, @shym, @Octachron , @pitag-ha, @panglesd)-locations-check option for coercions with ground (ocaml-ppx/ppxlib#428, @Octachron)ppxlib as-is, as well as ppx_sexp_conv in the same project (#386, @kit-ty-kate)File_path exports. (#381, @ceastlund)Ppxlib.Expansion_helpers with name mangling utilities from ppx_deriving (#370, @sim642)esequence right-associative. (#366, @ceastlund)Deriving.Generator (#368, @sim642)Code_path.enclosing_value (#349, @ceastlund)Code_path.enclosing_module (#346, @ceastlund)~enclose_intf and ~enclose_impl (#345, @ceastlund)--check: Allow toplevel_printer attributes (#340, @pitag-ha)result instead (#329, @panglesd)error_extensionf function to the Location module (#316, @panglesd)drop and as patterns (#313 by @Kakadu, review by @pitag-ha)input_name to the Expansion_context.Extension and Expansion_context.Deriver modules (#284, @tatchi)gen_symbol to strip previous unique suffix before adding a new one (#285, @ceastlund)name_type_params_in_td to use prefixes a, b, ... instead of v_x. (#285, @ceastlund)type_is_recursive and really_recursive where they would
consider a type declaration recursive if the type appeared inside an attribute
payload (#299, @NathanReb)Parser from the API (#263, @pitag-ha)Location: add set_filename and Error.get_location (#247, @pitag-ha)Syntaxerr from the public API. Doesn't affect any user in the
ppx universe (#244, @pitag-ha)Keyword.is_keyword to check if a string is an OCaml keyword
(#227, @pitag-ha)Lexer.keyword_table: use Keyword.is_keyword instead
(#227, @pitag-ha)Lexer from the API: it was the same as the compiler-libs
Lexer (#228, @pitag-ha)Ast_magic, Compiler_version, Js, Find_version,
Convert, Extra_warnings, Location_error, Select_ast and
Import_for_core from the API: they are meant for internal use and
aren't used by any current downstream user in the
ppx universe (#230, @pitag-ha)Location. They aren't used
by any current downstream user in the
ppx universe (#238, @pitag-ha)Location: make raise_errorf exception equivalent to exception
Error (#242, @pitag-ha)Pprintast: correctly pretty print local type substitutions, e.g.
type t := ... (#261, @matthewelse)Ast_pattern.esequence, for matching on any number of sequenced
expressions e.g. do_a (); do_b (); .... (#264, @matthewelse)Ast_io in order to allow reading AST values from binary
files (#270, @arozovyk)-as-ppx: take into account the -loc-filename argument (#197, @pitag-ha)register_transformation (#202, @pitag-ha)-cookie argument into account, also when the input is a
binary AST (@pitag-ha, #209)run_as_ppx_rewriter: take into account the arguments
-loc-filename, apply and dont-apply (#205, @pitag-ha)raise and update_loc
(#205, @pitag-ha)Ppxlib.Driver.map_signature (#194, @kit-ty-kate)code_path and tool_name to Expansion_context.Base
(#173, @jberdine)cases methods to traversal classes in Ast_traverse (#183, @pitag-ha)Driver.register_transformation: add optional parameter ~instrument
(#161, @pitag-ha)Location.init (#165, @pitag-ha)base and stdio dependencies (#151, @ceastlund)Driver.partition_transformation (#156, @NathanReb)ppxlib_traverse (#159, @ceastlund)Expansion_context and replace it with tool_name
(#149, @NathanReb)Ppxlib.Driver.map_structure to return a ppxlib's
structure instead of a Migrate_parsetree.Driver.some_structure.
(#153, @NathanReb)Ppxlib.Quoter. This module allows to generate hygienic code fragments in
the spirit of ppx_deriving. (#92, @rgrinberg)OCAML_ERROR_STYLE and
OCAML_COLOR in the standalone driver (#83, @NathanReb)Oops, we went looking but didn't find the changelog for this release 🙈
Oops, we went looking but didn't find the changelog for this release 🙈
Location.input_name to the original filename when reading a
binary AST (#.., @diml)Add an (** @inline *) to the include generated when silencing
warning 32 (#58, @trefis)
Add Ppxlib.mk_named_sig and Ppxlib.is_polymorphic_variant (#57,
@trefis)
The ppxlib team is pleased to announce the release of
ppxlib 0.4.0. This release adds better
support for defining compile-time interpretation of dotted operators such as
+.+ and also improves integration with other tools such as reason or metaocaml
by no longer complaining about attributes generated by these tools. In
particular, ppxlib now treats all attributes whose name start with an _ as
machine generated attributes and doesn’t complain if it can’t decide whether
they have been correctly interpreted or not. FTR, ppxlib tries to detect
attributes and extension points that are dead-code, in order to catch typing
mistakes or misplacement.
_ (#46, fix #40, @diml)special_function rule for dotted operators and allow
Longident.parse to parse dotted operators (#44, @Octachron)dune and remove use of bash (#45, @rgrinberg)_ (#46, @diml)reason and refmt namespaces (#46, @diml)metaocaml namespace (#50, @rgrinberg)-loc-filename is passed (#55, @hhugo)Attribute.declare_with_name_loc (#33, @diml)Oops, we went looking but didn't find the changelog for this release 🙈
Oops, we went looking but didn't find the changelog for this release 🙈
-safe-string (#10, @hhugo)Oops, we went looking but didn't find the changelog for this release 🙈