Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lift ppx expansion errors as extension nodes to top level of file #358

Merged
merged 8 commits into from
Jul 26, 2022

Conversation

ceastlund
Copy link
Collaborator

Changes map_top_down to collect errors explicitly. Like #357 but with fewer added/duplicated classes, and with errors mostly handled by a With_errors monad.

Signed-off-by: Carl Eastlund <ceastlund@janestreet.com>
Signed-off-by: Carl Eastlund <ceastlund@janestreet.com>
Signed-off-by: Carl Eastlund <ceastlund@janestreet.com>
Signed-off-by: Carl Eastlund <ceastlund@janestreet.com>
Copy link
Member

@pitag-ha pitag-ha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I like the idea of lifting the errors and treating them at signature/structure level a lot, so either #357 or this PR are definitely a good improvement! As a side-note: doing so introduces one small inconsistency: ppxlib errors will be lifted, while embedded errors by context free rules will stay at the nodes they arise at. I don't think that's a problem though.

The main differences I see with #357 are:

  • the map_top_down class doesn't get duplicated. I think that's a good thing. Folding errors when AST traversing, to embed them at the toplovel structure/signature. #357 could very easily be adapted to do the same though, right?
  • the Ppxlib.Ast_traverse.map_with_expansion_context gets erased. Could also be adapted though. See my comment about that below concerning bisect_ppx.
  • error handling is factored through the new With_errors monad. That seems very nice to me and makes things very well readable!

I haven't had a close look though. Are there more differences?

In any case, if you aren't in a strong hurry with #352, I think it would be cool to wait for @panglesd to come back from vacation to see what he thinks, both in general about this PR and compared to his #357.

I haven't fully reviewed yet, but I've already dropped some comments below.

CHANGES.md Outdated Show resolved Hide resolved
dune-project Outdated Show resolved Hide resolved
src/ast_traverse.mli Show resolved Hide resolved
src/driver.ml Outdated Show resolved Hide resolved
traverse_builtins/ppxlib_traverse_builtins.ml Show resolved Hide resolved
Copy link
Collaborator

@panglesd panglesd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that using a lift_map rather than a fold_map is better (we do not need to pass the accumulator when calling methods).

It also leads with the infix syntax to a cleaner code than the fold_map, although I generally prefer the let syntax (unfortunately custom let syntax is unavailable in old ocaml versions...)

I have small comments on the code or the names, but that is good for merge on my side!

src/ast_traverse.ml Outdated Show resolved Hide resolved
src/ast_traverse.ml Outdated Show resolved Hide resolved
src/ast_traverse.ml Outdated Show resolved Hide resolved
src/context_free.ml Outdated Show resolved Hide resolved
src/context_free.ml Outdated Show resolved Hide resolved
src/context_free.ml Show resolved Hide resolved
src/context_free.mli Outdated Show resolved Hide resolved
traverse_builtins/ppxlib_traverse_builtins.ml Show resolved Hide resolved
dune-project Outdated Show resolved Hide resolved
Signed-off-by: Carl Eastlund <ceastlund@janestreet.com>
…on_context_and_errors.

Signed-off-by: Carl Eastlund <ceastlund@janestreet.com>
Signed-off-by: Carl Eastlund <ceastlund@janestreet.com>
Signed-off-by: Carl Eastlund <ceastlund@janestreet.com>
@ceastlund ceastlund merged commit 5787326 into ocaml-ppx:main Jul 26, 2022
pitag-ha added a commit to pitag-ha/opam-repository that referenced this pull request Oct 5, 2022
CHANGES:

- Make `esequence` right-associative. (ocaml-ppx/ppxlib#366, @ceastlund)

- Deprecate unused attributes in `Deriving.Generator` (ocaml-ppx/ppxlib#368, @sim642)

- Remove a pattern match on mutable state in a function argument. (ocaml-ppx/ppxlib#362, @ceastlund)

- Add code-path manipulation attributes. (ocaml-ppx/ppxlib#352, @ceastlund)

- Update context-free rules to collect expansion errors generated by ppxlib and
  propagate them to top level without failing. (ocaml-ppx/ppxlib#358 and ocaml-ppx/ppxlib#361, @ceastlund)
pitag-ha added a commit to pitag-ha/opam-repository that referenced this pull request Oct 6, 2022
CHANGES:

- Make `esequence` right-associative. (ocaml-ppx/ppxlib#366, @ceastlund)

- Deprecate unused attributes in `Deriving.Generator` (ocaml-ppx/ppxlib#368, @sim642)

- Remove a pattern match on mutable state in a function argument. (ocaml-ppx/ppxlib#362, @ceastlund)

- Add code-path manipulation attributes. (ocaml-ppx/ppxlib#352, @ceastlund)

- Update context-free rules to collect expansion errors generated by ppxlib and
  propagate them to top level without failing. (ocaml-ppx/ppxlib#358 and ocaml-ppx/ppxlib#361, @ceastlund)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants