-
Notifications
You must be signed in to change notification settings - Fork 29
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
Ppxlib #54
Ppxlib #54
Conversation
(* The equivalent of not specifying the variance explicitly. | ||
Since the very purpose of ppx_import is to include the full definition, | ||
it should always be sufficient to rely on the inferencer to deduce variance. *) | ||
(Ppxlib.Asttypes.NoVariance, Ppxlib.Asttypes.NoInjectivity) )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not sure about that one. Is Ppxlib.Asttypes.NoInjectivity
correct ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was introduced in ppxlib 0.22.0
Looks like Invariant
was replaced by NoVariant but I've no clue what should be the injectivity
😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is indeed tricky stuff, @gasche do you know who could help with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked at this (sorry for the delay). It's a bit tricky but I think that the current code in the PR is correct:
- for abstract type, the default is "non injective", so
NoInjectivity
is the conservative choice - non-abstract types are always injective, so you could use
Injective
here, but it looks like the OCaml parser usesNoInjective
by default as well and lets the type-checker figure things out afterwards.
src/ppx_import.ml
Outdated
let find_attr s attrs = | ||
try | ||
Some | ||
(List.find (fun { attr_name = x; _ } -> x.txt = s) attrs).attr_payload | ||
with Not_found -> None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find the Ast_convenience.find_attr
equivalent so I just inlined the function
Thanks a lot @tatchi ! I will give it some extended testing this week, I have some development which make extensive use of ppx_import I'm OK with the code formatting, tho I do believe that it'd be better if you can submit it as a separate PR so we can review this one free of formatting changes. If we are gonna format ppx_import automatically we should have it happen as part of the CI , add the ocamlformat config, and a makefile target |
Those who do the work decide; @ejgallego if you are doing the main work of integrating this nice-sounding PR, you get to decide on the formatting :-) |
I have a similar view, if @tatchi who is writing this PR would like to have the code formatted, that's fine to me. |
Needs fixing for OCaml versions < 4.12:
|
8d13b18
to
ceb74c5
Compare
The reason why I formatted the code is because I'm not used to doing that manually. Therefore, I knew I was going to auto-format the files changed by this PR, and figured it would be better to have a first commit that only formats the files. That would make the review easier to avoid extra diff related to formatting changes. I can definitely revert my commit and try to format the changes by hand if you prefer 😄
I'm a bit lost between all these |
Would that make sense to restrict |
Personally I think that requiring (OCaml >= 4.05) is now very reasonable. |
On the contrary, I'd say let's try to avoid doing more work than what we need. If you pass me your ocamlformat config we can already merge the formatting changes in a separate PR. |
I think that what @ejgallego has in mind is to have a first PR (or himself committing directly) with your pure-reformat change, and a second PR with the actual changes, in the interest of making the "whole diff" review of the PR easier. |
Sounds good to me, I'll open a PR with the formatting changes 😊 |
97732da
to
7db8969
Compare
I rebased my changes on top of master. The second commit bumps |
Thanks @tatchi , I'd prefer to have as a separate PR if you don't mind, so review is easier. I assume the PR is ready for review, correct? What about the CI failure? |
72b46db
to
c51d46f
Compare
Alright, I removed the commit :)
Yes, it should be ready for review. The CI was failing for OCaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
I will leave a couple of days to get comments, do some more testing on my own, then merge.
I skimmed the code and it looks overall fine (the port is rather non-invasive, which is good news). There is one question on variance that is subtle, I will look at it later. (It's about moving from one version of the AST to another, rather than ppxlib per se, in a corner case of the type declaration syntax.) My experience with these changes is that there are some failures that are not caught by running the code, but by trying them in the real world. Stuff like breakage with older OCaml versions, or breakage when people combine it with other ppxes, or use a non-Dune build system. I think that the real test with this PR will be building the reverse dependencies of |
Note that the opam file seems to have a couple of issues:
@tatchi , if you feel like addressing these issues it is fine, otherwise I'll tweak them myself before the release. Regarding my testing, I'm getting this problem: Error: Type unsupported for ppx [of_sexp] conversion
File "serlib/ser_sorts.ml", line 19, characters 2-25:
19 | [%import: Sorts.family] where the type family =
[%import: Sorts.family]
[@@deriving sexp,yojson] and the original type is: type family = InSProp | InProp | InSet | InType the build definition for this library is (library
(name serlib)
(public_name coq-serapi.serlib)
(synopsis "Serialization Library for Coq")
(preprocess (staged_pps ppx_import ppx_sexp_conv ppx_deriving_yojson))
(libraries coq.stm sexplib)) I tried a few tweaks without success, didn't investigate more yet. This is a showstopper I'm afraid, as this is a basic use case of ppx_import IMHO. Let me of course know if you want me to produce a self-contained reproduction case. |
I rebased the branch to bring in #61 (the failing test) and modified the code to use the new ppx_import syntax. The relevant commit is 23fd6a8 To make it work, I slightly had to change the For the For the The challenge I faced is that there were some code paths that were using the |
What's the status of this PR? I think it's based on the latest ppxlib additions and should be ready for review isn't it? I'm currently working on some follow up changes and bug fixes on ppxlib and wanted to make sure that If I was wrong to assume that the need to discuss how |
From what I remember, I should have adapted the code to what is described in this PR: ocaml-ppx/ppxlib#271 (comment) (or at least from what I understood). All the current + the failing test are passing. So yes it should be ready for a review 😁 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for all the work @tatchi and sorry for the delay in having another look at it! By the way, you can always ping me.
The challenge I faced is that there were some code paths that were using the
module_type
received as input, modifying some of its properties and returned it. Since we no longer receive amodule_type
as input, I had now to construct one from scratch. Not sure how it matters, especially since all the tests are passing (including the one that was failing before).
See my comment below about that.
let psig = | ||
psig_of_tsig ~subst (List.map Compat.migrate_signature_item tsig) | ||
in | ||
Ast_helper.Mty.mk ~attrs:[] (Pmty_signature psig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we no longer receive a
module_type
as input, I had now to construct one from scratch. Not sure how it matters, especially since all the tests are passing (including the one that was failing before).
This place is what you were referring to, isn't it?
I'm not sure if that ever might happen, but if someone wrote
module type Foo = [%import: ...] [@inner_attribute] [@@deriving ...]
then the inner attribute would get lost now.
@ejgallego, do you think that's a problem? By the way, I'm not really sure: what's the use case of ppx_import
in the context of module types? Is it really also for derivers (as in my example above) or is it actually something different? Or both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't tell, I'll test when I can, but I think it should be OK for my use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fingers crossed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you have use cases of ppx_import
on module types yourself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you have use cases of ppx_import on module types yourself?
I was experimenting with something like that to avoid boilerplate as someone recently pointed out to me that this was possible, but not sure we have something in production, need to check anyways, I think coq-serapi has ~700 import statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ejgallego, how is this going? Have you already had time to test this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope sorry, but will go ahead ASAP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ejgallego, kind reminder. Have you already had the chance to look into this? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tatchi and @ejgallego, we've now released ppxlib.0.24.0 which contains all the new changes needed (see entries 2, 3 and 4 in release notes). Could you unpin ppxlib and instead bound it to |
Co-authored-by: Sonja Heinze <[email protected]>
Thanks @pitag-ha for the review 😊 I unpinned |
Hi folks, I could finally perform some testing on my end, and this PR seems to work very well! I thus propose to merge and do a release if everyone is happy. |
Thanks for taking the time to test it 🤗 All fine for me to merge it but,
to let you know, I noticed that it doesn't work with OCaml 4.13 (due to a
change in the AST). I've a local branch where I should have fixed that.
I was waiting for that PR to be merged before opening a new one with the
above mentioned fix. Up to you to decide if it should be included in the
next release :)
Le jeu. 6 janv. 2022 à 19:38, Emilio Jesús Gallego Arias <
***@***.***> a écrit :
… Hi folks, I could finally perform some testing on my end, and this PR
seems to work very well!
I thus propose to merge and do a release if everyone is happy.
—
Reply to this email directly, view it on GitHub
<#54 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABKV7VEEW3N7H4Y6TCLSLE3UUXORZANCNFSM446TYDEQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I think no problem at all; I propose to merge on Monday evening, so we can maybe cook the release end of next week. |
Thanks @tatchi and @pitag-ha for the hard work, and thanks @ejgallego for the review! @ejgallego, will you take care of preparing a new release? |
Yup, as soon as @tatchi adds the PR for 4.13 support.
Sure, I think it will be 1.9.0 tho, as 2.0 may be reserved for #62 if finally goes ahead. |
I will open a PR for that later on today :) |
CHANGES: * Migrate to ppxlib ocaml-ppx/ppx_import#54 , closes ocaml-ppx/ppx_import#44 (tatchi) * Drop support for OCaml `4.04.2`. Minimal supported version is now `4.05.0` ocaml-ppx/ppx_import#54 (tatchi) * Bump minimum dune version to 1.11 ocaml-ppx/ppx_import#56 (tatchi) * Update CI to test OCaml 4.12.0, no changes required (ocaml-ppx/ppx_import#53, Emilio J. Gallego Arias) * Remove the OCaml upper bound in the opam file (ocaml-ppx/ppx_import#53, Emilio J. Gallego Arias, kit-ty-kate)
This is my attempt at addressing ocaml-ppx/ppxlib#143. It would need careful review as I'm definitely not a
ppx
expert. At least the tests are passing which I guess is a good sign 😁ppxlib
Closes #44