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

Support class type declarations in derivers #538

Merged
merged 1 commit into from
Nov 27, 2024

Conversation

patricoferris
Copy link
Collaborator

This PR adds support for class type declarations, which I mistook #509 for. All the same, seems like a good feature to add given ppxlib didn't support it.

It reuses some code from type declarations as they are pretty similar but there is Recursive flag for class types (are the just always recurive?). This bit could perhaps use some more work.

Copy link
Collaborator

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

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

This looks good to me! I can't think of a good reason why not to add this.

I'm curious as to why you've added the Class_decl context and handled it everywhere without exposing it. Is this an omission or is there a particular reason why you did this that I missed?

I think only allowing it for class types is fair given that's what we do for modules as well, although I could see how it would be useful to allow deriving values from class/module declarations but I think it's a topic for another time.

@@ -105,10 +105,12 @@ with type deriver := t

val add :
?str_type_decl:(structure, rec_flag * type_declaration list) Generator.t ->
?str_class_type_decl:(structure, class_type_declaration list) Generator.t ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change could potentially break some rev deps, although I deem it quite unlikely.

I think it's fair to treat this as non breaking from our perspective given how the add and add_alias function are used in practice but still wanted for us to keep this in mind before we release this!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed.

As a litmus test, I tested this change against 50 revdeps without any failures due to this. There were failures because of flakey tests and no solves.

@NathanReb
Copy link
Collaborator

This needs a changelog entry!

Copy link
Collaborator

@NathanReb NathanReb left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@patricoferris patricoferris merged commit a4004e2 into ocaml-ppx:main Nov 27, 2024
6 checks passed
@patricoferris patricoferris deleted the deriving-classes branch November 27, 2024 23:39
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.

2 participants