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

add comparison function for Pp.Ast.t #9

Conversation

Alizter
Copy link
Contributor

@Alizter Alizter commented Aug 22, 2023

No description provided.

src/pp.ml Outdated
let compare_triple f g h (x, y, z) (a, b, c) =
compare_both f (compare_both g h) (x, (y, z)) (a, (b, c))

let compare compare_tag =
Copy link
Contributor

Choose a reason for hiding this comment

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

You can define it directly on Pp.t

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't compare Format so we can just use this together with to_ast for Pp.

Copy link
Contributor

Choose a reason for hiding this comment

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

No. that's unnecessarily slow. Just raise if you get Format. We should just get rid of that constructor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove Format in another PR. I've made Pp.compare which will raise Invalid_argument if two Pp.of_fmt values are provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

To clarify, I made a mistake not listening to Jeremie here: #1

What I think we can do is introduce a Pp.Fmt submodule that allows to inject this Format constructor. The core Pp.t should stay serializable, comparable, and all that good stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That seems sensible, but it is beyond the scope of what I am willing to do at the moment. We should definitely take another look at that in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, could you add a CHANGES entry?

@Alizter Alizter force-pushed the ps/branch/add_comparison_function_for_pp_ast_t branch 2 times, most recently from f01591d to 438153f Compare August 22, 2023 15:45
@rgrinberg rgrinberg added this to the 1.2.0 milestone Aug 22, 2023
@Alizter Alizter force-pushed the ps/branch/add_comparison_function_for_pp_ast_t branch from 438153f to fee774d Compare August 22, 2023 16:22
@Alizter
Copy link
Contributor Author

Alizter commented Aug 22, 2023

@rgrinberg Added a CHANGES entry. (Before I also added a test).

@Alizter Alizter closed this Aug 22, 2023
@Alizter Alizter reopened this Aug 22, 2023
@rgrinberg rgrinberg merged commit 8faed8b into ocaml-dune:master Aug 22, 2023
5 of 7 checks passed
@Alizter Alizter deleted the ps/branch/add_comparison_function_for_pp_ast_t branch August 22, 2023 16:25
emillon added a commit to emillon/opam-repository that referenced this pull request Sep 15, 2023
CHANGES:

- Add `Pp.compare` (ocaml-dune/pp#9, @Alizter)
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
CHANGES:

- Add `Pp.compare` (ocaml-dune/pp#9, @Alizter)
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