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

feat(ppx): separate @@deriving abstract into jsProperties, getSet #987

Merged
merged 5 commits into from
Dec 17, 2023

Conversation

anmonteiro
Copy link
Member

No description provided.

Copy link
Member

@jchavarri jchavarri 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 this looks great. As mentioned, it's inconsistent now to have ppx payloads with OCaml casing like the ones added here and JS casing like jsConverter, but it's not a big deal in any case.

Deriving.Generator.V2.make (args ()) (fun ~ctxt:_ (rf, tdcls) ->
Ast_derive_abstract.handleCstrTdclsInSig rf tdcls)
in
Deriving.add ~str_type_decl ~sig_type_decl "make_opt_keys"
Copy link
Member

Choose a reason for hiding this comment

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

is "make" necessary, or could it be just opt_keys? or opt_js_keys as you mentioned including "js" somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, I'm open to changing the name; I'd prefer keeping something that mentions it makes a JS object, e.g. jsConstructor or jsObject

Copy link
Member

Choose a reason for hiding this comment

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

I was thinking about the JS hasOwnProperty method. It seems a property is the mix of a key and a value, so maybe the deriver name should include it.

It'd be nice to define it like "constructor that skip properties in the JS object if the field is None", maybe optJsProperties, makeOptProperties? or skipPropertiesConstructor?

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer keeping something that mentions it makes a JS object,

I am not sure this is very informative. All records compile now to JS objects so a name related to that wouldn't be very meaningful imo.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, I called it jsProperties to unblock the PR, but we can brainstorm a better name later on.

ppx/melange_ppx.ml Show resolved Hide resolved
test/blackbox-tests/deriving-separate.t Show resolved Hide resolved
ppx/ast_derive/ast_derive_abstract.ml Outdated Show resolved Hide resolved
@anmonteiro
Copy link
Member Author

it's inconsistent now to have ppx payloads with OCaml casing like the ones added here and JS casing like jsConverter, but it's not a big deal in any case.

oh absolutely. I'll change that before merging for sure

@anmonteiro
Copy link
Member Author

9d55611 implements abstract in terms of the 2 new ones.

Will deprecate it in a subsequent PR.

@anmonteiro anmonteiro force-pushed the anmonteiro/split-deriving-abstract branch from 4640961 to 4afbf67 Compare December 17, 2023 15:55
@anmonteiro anmonteiro changed the title feat(ppx): separate @@deriving abstract into make_opt_keys, getters_setters feat(ppx): separate @@deriving abstract into jsProperties, getSet Dec 17, 2023
@anmonteiro anmonteiro merged commit 2163b00 into main Dec 17, 2023
4 checks passed
@anmonteiro anmonteiro deleted the anmonteiro/split-deriving-abstract branch December 17, 2023 16:25
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.

None yet

2 participants