-
Notifications
You must be signed in to change notification settings - Fork 89
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
Port standard plugins to ppxlib registration and attributes #263
Conversation
(* TODO: add to ppxlib? *) | ||
let ebool: _ Ast_pattern.t -> _ Ast_pattern.t = | ||
Ast_pattern.map1 ~f:(function | ||
| [%expr true] -> true | ||
| [%expr false] -> false | ||
| _ -> failwith "not bool") | ||
let args () = Deriving.Args.(empty +> arg "with_path" (ebool __)) |
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.
Handling the arguments in show { with_path = false }
using ppxlib was surprisingly annoying. Especially since the argument is always option
, so the default case needs to be handled below separately. Maybe would be useful to have some arguments with defaults in ppxlib?
Hey @sim642, even though I'm still not finding the time to review (as we've mentioned already, finding time to work on PPX-related things is rare), I at least already wanted to take the time to thank you. Thanks for the PR! I personally would have preferred to write a new bunch of standard derivers to have more freedom to improve things (as started here, but never finished/gotten far). However, I appreciate the work and it's definitely good to have these standard derivers written in |
Very sorry about the delay. I'll put that on the top of my todo list. (Although next week I'm on holidays). |
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.
Few comments, restricted to the API part (I'll continue with the plugins tomorrow).
Is Arg
deprecated in favour of Ast_pattern
?
I guess functions which have a direct equivalent in ppxlib should be deprecated. So Quoting
functions should be deprecated, as well as mangle_lid
, and mangle_type_decl
.
(Or is there a reason not to do so?)
Finally, it could be nice to add a message to the deprecated alerts: [@@ocaml.deprecated "Use Ppxlib.register ... instead]
(I think that is valid OCaml).
Regarding the deprecations, it would be fine to also just exclude them from this PR. If I remember correctly, the original inspiration was #250, which proposes to deprecate the entire API. However, given warnings-as-errors in many projects, this might cause unnecessary breakage of derivers still built on ppx_deriving. Having everything ported would be nice, but these things don't have to be coupled. I might've also used the deprecation warnings as a guide to find any usages to port within these standard plugins.
It's not even marked deprecated here right now, but I think I wanted to make as big step towards fully using ppxlib as possible, hence the switch to |
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 went through the plugins, and the modifications look good!
However, I agree that they sometimes show some holes or defects in the ppxlib API. I summarize them here:
Quoter.sanitize
should not useRecursive
Code_path.main_module_name
should use the true input filename and not be subject to line directives- Add
ebool : (bool, 'a, 'b) t -> (expression, 'a, 'b) t
(there is already an open issue about that, Ast_pattern: augment API withebool
,pbool
helper, and a newmap
. ppxlib#399) - Add some functions in the API to handle "unit" attributes:
val declare_flag : string -> 'a Context.t -> ('a, unit) t
val check_flag : ('a, unit) t -> ?mark_as_seen:bool -> 'a -> bool
- Add a way to define arguments with defaults
val arg_with_default :
string ->
(expression, 'a -> 'a, 'a) Ast_pattern.t ->
default:'a ->
'a param
- fix on the
optional
issue new bug in ppx_deriving ("optional" no longer works) #247 -- optional parameter for ppx_bin_prot ppxlib#125. - Combine the extraction of attributes from two nodes of the AST. For this one, I'm less sure it should be in the
ppxlib
API...
Most of them are not too hard to solve. I will open the relevant issues, and label them as good first issues (can be useful for an Outreachy applicant)!
For turning Recursive to
Nonrecursivein
Quoter`, you can make a PR directly with this, since you offered it, thanks!
About the inclusion of deprecation of the API in this PR: I don't have a strong opinion at all... If there is a clear indication of what should be used instead, and it's easy to fix (for instance, the But, I agree that it is not completely necessary, and might upset some people. Maybe, a mention in the |
Co-authored-by: panglesd <[email protected]>
Co-authored-by: panglesd <[email protected]>
This reverts commit 4c9178c.
I've just excluded all the deprecations from this PR right now to avoid blocking this by those additional discussions and decisions. |
I'm one of the few maintainers of ppx_deriving, mostly inactive. I can give some time next week to look at this again and move towards merging, but I prefer to let other people take care of releases. Do we have a volunteer to cut out a new release? (I'm happy to give commit rights to enable this.) |
Hey! This has been sitting around for quite a while now. It'd be great to get this merged and released as well. It's been a long while since ppx_deriving has seen a release (even #252 hasn't made it). |
Hello ! Sorry I'm off during one month, I will assess whether I accept this responsibility when I come back! |
I don't :) Let's see if @panglesd happens to want them when he's back. Btw, what's the current maintenance status of
Is that right?
Thank you, @gasche! If that would help, I could answer questions about Ppxlib if they come up. |
Sorry for the long delay, I'm back. @NathanReb since you have joined as a ppxlib maintainer, there is a new variable in the equation! Would you be interested in any activity involving this repository? If not, I will be happy to take care of cutting a release that includes this change. That being said, I can't commit to be an active maintainer in the long run! |
I'd be happy to take part in smoothing things out here yes! Will need to catch up a bit but merging and releasing this work seems important for the ppx ecosystem so I'll gladly to take care of it! |
@gasche could you add @NathanReb ? I thought i had the rights to do that but turns out i only have access to some of the settings and not this one (github maintainer vs. admin) |
Done, and I made you @kit-ty-kate an Admin. Thanks! |
@sim642 sorry for the long wait. I will work on getting this merged and will start reviewing it. Are you still willing to work on this if there are changes to be made? |
Yes, that shouldn't be an issue. |
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 looks good! I only have one suggestion to make the attribute_get2
a bit easier to use and more readable!
Co-authored-by: Nathan Rebours <[email protected]>
Sorry again for the long delays and thanks for taking the time to get back to this @sim642. Really appreciate it! Let's merge this! |
CHANGES: * Port standard plugins to ppxlib registration and attributes ocaml-ppx/ppx_deriving#263 (Simmo Saan) * Optimize forwarding in eq and ord plugins ocaml-ppx/ppx_deriving#252 (Simmo Saan) * Delegate quoter to ppxlib ocaml-ppx/ppx_deriving#263 (Simmo Saan) * Introduce `Ppx_deriving_runtime.Stdlib` with OCaml >= 4.07. This module already exists in OCaml < 4.07 but was missing otherwise. ocaml-ppx/ppx_deriving#258 (Kate Deplaix)
CHANGES: * Fix a bug in `[@@deriving make]` that caused errors when it was used on a set of type declarations containing at least one non record type. ocaml-ppx/ppx_deriving#281 (@NathanReb) * Embed errors instead of raising exceptions when generating code with `ppx_deriving.make` ocaml-ppx/ppx_deriving#281 (@NathanReb) * Remove `[%derive.iter ...]`, `[%derive.map ...]` and `[%derive.fold ...]` extensions ocaml-ppx/ppx_deriving#278 (Simmo Saan) * Port standard plugins to ppxlib registration and attributes ocaml-ppx/ppx_deriving#263 (Simmo Saan) * Optimize forwarding in eq and ord plugins ocaml-ppx/ppx_deriving#252 (Simmo Saan) * Delegate quoter to ppxlib ocaml-ppx/ppx_deriving#263 (Simmo Saan) * Introduce `Ppx_deriving_runtime.Stdlib` with OCaml >= 4.07. This module already exists in OCaml < 4.07 but was missing otherwise. ocaml-ppx/ppx_deriving#258 (Kate Deplaix)
This realizes part of #250:
Deprecates only parts of ppx_deriving API, namely ppx_deriving deriver registration and attribute support. All the other utility functions remain undeprecated since many are still missing from ppxlib (Ppx_deriving utility functions ppxlib#317).Notably, this makes
[@@deriving_inline ...]
work on these standard derivers.TODO
derive.*
extensions support?