Skip to content

Commit

Permalink
Update docs and changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymody committed Feb 12, 2025
1 parent 39c582d commit 5f145b9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
unreleased
----------

- Add the `[@@@expand_inline]` transformation and support for floating attribute context
free transformations. (#560, @jaymody)

- Export `Ast_pattern.fail`. (#563, @ceastlund)

- Make `Ast_traverse.sexp_of` more concise, and add a test. (#561, @ceastlund)
Expand Down
36 changes: 36 additions & 0 deletions doc/writing-ppxs.mld
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,42 @@ This mechanism is implemented for derivers implemented in [ppxlib] and is conven

Inline derivers will generate a [.corrected] version of the file that Dune can use to promote your file. For more information on how to use this feature to remove a dependency on [ppxlib] and a specific PPX from your project, refer to {{:https://ocaml.org/docs/metaprogramming#dropping-ppxs-dependency-with-derivinginline}this guide}.

In addition to [[@@deriving_inline]], there is also [[@@@expand_inline <structure payload>]] and [[@@@expand_inline: <signature payload>]]. These can be use to inline code generated by other context free transformations (not just derivers):

{@ocaml[
[@@@expand_inline let _ = [%add_suffix "foo"]]

let _ = "foo_suffixed"

[@@@end]

module type S = sig
[@@@expand_inline: type foo = [%pair_of string]]

type foo = string * string

[@@@end]
end
]}

In addition to [[@@deriving_inline]], there is also [[@@@expand_inline <structure payload>]] and [[@@@expand_inline: <signature payload>]]. These can be use to inline code generated by other context free transformations (not just derivers):

{@ocaml[
[@@@expand_inline let _ = [%add_suffix "foo"]]

let _ = "foo_suffixed"

[@@@end]

module type S = sig
[@@@expand_inline: type foo = [%pair_of string]]

type foo = string * string

[@@@end]
end
]}

{1 Integration with Dune}

If your PPX is written as a Dune project, you'll need to specify the [kind]
Expand Down

0 comments on commit 5f145b9

Please sign in to comment.