Skip to content

Add a deprecation warning to > in Class #15802

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

Merged
merged 2 commits into from
Mar 28, 2022

Conversation

proux01
Copy link
Contributor

@proux01 proux01 commented Mar 13, 2022

This follows a discussion in #2643

Currently, field :> field_type declares field a coercion in every record declaration, except typeclasses where it is instead declared a typeclass instance. It seems more principled to remove that exception (so in typeclasses, both an instance and a coercion are declared).

This is currently only introducing a warning to start a deprecation phase.

Adresses #2643 #9014

  • Added / updated test-suite.
  • Added changelog.
  • Added / updated documentation.

Overlays (backward compatibles, kindly provided but don't need to be merged in sync with the current PR):

@proux01 proux01 force-pushed the deprecate_backinstance branch from 94329ee to 4eee9a6 Compare March 13, 2022 19:34
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Mar 13, 2022

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Mar 14, 2022

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

@proux01 proux01 force-pushed the deprecate_backinstance branch from 9628702 to a876a4a Compare March 15, 2022 18:02
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Mar 15, 2022

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

proux01 added a commit to proux01/analysis that referenced this pull request Mar 15, 2022
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Mar 15, 2022

🔴 CI failures at commit a876a4a without any failure in the test-suite

✔️ Corresponding jobs for the base commit 47ad43b succeeded

❔ Ask me to try to extract minimal test cases that can be added to the test-suite

🏃 @coqbot ci minimize will minimize the following targets: ci-category_theory, ci-fiat_crypto_legacy, ci-fiat_parsers, ci-hott
  • You can also pass me a specific list of targets to minimize as arguments.

@coqbot-app
Copy link
Contributor

coqbot-app bot commented Mar 15, 2022

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

proux01 added a commit to proux01/HoTT that referenced this pull request Mar 15, 2022
proux01 added a commit to proux01/fiat that referenced this pull request Mar 15, 2022
proux01 added a commit to proux01/category-theory that referenced this pull request Mar 15, 2022
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Mar 15, 2022

🔴 CI failures at commit 4abedb4 without any failure in the test-suite

✔️ Corresponding jobs for the base commit 47ad43b succeeded

❔ Ask me to try to extract minimal test cases that can be added to the test-suite

🏃 @coqbot ci minimize will minimize the following targets: ci-category_theory, ci-fiat_crypto_legacy, ci-fiat_parsers, ci-hott
  • You can also pass me a specific list of targets to minimize as arguments.

@proux01 proux01 force-pushed the deprecate_backinstance branch from 4abedb4 to e6dda16 Compare March 15, 2022 21:30
@coqbot-app
Copy link
Contributor

coqbot-app bot commented Mar 15, 2022

The job library:ci-fiat_crypto_legacy has failed in allow failure mode
ping @JasonGross

@proux01 proux01 added kind: fix This fixes a bug or incorrect documentation. part: typeclasses The typeclass mechanism. part: coercions The coercion mechanism. part: records Record types, Structures, etc. needs: changelog entry This should be documented in doc/changelog. labels Mar 16, 2022
@SkySkimmer
Copy link
Contributor

This isn't a deprecation, it's a behaviour change.

@proux01 proux01 added the needs: documentation Documentation was not added or updated. label Mar 16, 2022
@proux01 proux01 changed the title Deprecate :> for typeclasses? Declare coercion for :> even for typeclasses Mar 16, 2022
@proux01
Copy link
Contributor Author

proux01 commented Mar 16, 2022

Yes, you read it before I had time to update the title, fixed.

Copy link
Contributor

@SkySkimmer SkySkimmer left a comment

Choose a reason for hiding this comment

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

We should have a deprecation phase

@proux01
Copy link
Contributor Author

proux01 commented Mar 16, 2022

You mean putting a warning telling a coercion will be added in the future? why not.

@Alizter
Copy link
Contributor

Alizter commented Mar 16, 2022

I think it will take at least 3 version before we can make :> mean coercion. We need two for the deprecation phase, and ideally we would leave one version where it isn't supported at all to make sure nobody accidentally starts using coercions.

I see that you've used export for the locality of the existing instances, was this the case before?

@proux01
Copy link
Contributor Author

proux01 commented Mar 16, 2022

and ideally we would leave one version where it isn't supported at all to make sure nobody accidentally starts using coercions.

I'm not sure I get this last one, we are talking about adding coercions, not deleting anything. So for me, this third version would be the exact same as currently: no change and no warning, what's the point?

@proux01
Copy link
Contributor Author

proux01 commented Mar 16, 2022

We could have a version where :> in Class gives a plain error, but that's likely to break much more code than needed. About a small third of the CI (14 to 19 targets) seems to use the feature (instance), most of them not caring about the coercion and some explicitly declaring them. In the CI, only category-theory needs the instances but is harmed by the coercions.

@RalfJung
Copy link
Contributor

RalfJung commented Jun 22, 2022

I agree that having the same syntax do two different things is confusing, and I was startled by this myself many years ago. However, the new behavior of :> on a Class (both instance and coercion) is essentially never what you want, and it is still different from what :> does everywhere else. So this makes the situation strictly worse than it was before.

The proper solution, IMO, is to have a syntax for only the coercion, and a syntax for only the instance. I think the transition plan for this should look as follows:

  • Add the "only instance" syntax
  • A release later, deprecate the :> instance in Class
  • A release (or several releases) later, change the meaning of :> in Class from "only instance" to "only coercion"

This gives precedence to the :> usecase outside of Class. My personal preference would be for :> to mean "only instance" and use some other syntax for "only coercion". At least for the code I maintain, that would lead to much less churn -- but this of course depends heavily on the style of one's codebase.

@SkySkimmer
Copy link
Contributor

A release later, deprecate the :> instance in Class

Why wait? If we want 2 releases with both syntaxes we can just keep warning for both releases.

@SkySkimmer
Copy link
Contributor

cc @ppedrot we may want to revert this PR for 8.16

@RalfJung
Copy link
Contributor

Why wait? If we want 2 releases with both syntaxes we can just keep warning for both releases.

We'll have to allow that warning in std++ and Iris then if we want to support more than one Coq release. I think it is nicer to users to wait a bit before deprecating things in favor of new things that have only just been introduced. (The quick deprecation of Hint Rewrite without Global/Local is still rippling through our ecosystem.)

For now this is only a deprecation, and we don't have plans to go through with removing it until we provide an alternative shorthand for instances.

Ah, I misunderstood then, I thought this was a behavior change. Thanks for clarifying.

Still I think this deprecation is too early. Unless there is some automatic way for us to adjust the code to the new style, we will just allow the warning and wait for such an automatic way to be available -- which seems a lot easier when it is about replacing :> with ::, rather than adding some Existing Instance stuff after the Class declaration.

@SkySkimmer
Copy link
Contributor

We'll have to allow that warning in std++ and Iris then if we want to support more than one Coq release. I think it is nicer to users to wait a bit before deprecating things in favor of new things that have only just been introduced

I disagree, IMO the warning is the primary way to communicate intended changes to users (we can't expect everyone to watch PRs) so it's better to have it early. Allowing the warning if you don't want to deal with it immediately is a fine solution.

@RalfJung
Copy link
Contributor

RalfJung commented Jun 22, 2022

Could the warning state that the suggested alternative needs Coq version X to work? The Hint Rewrite thing comes up every few months (some repo I haven't looked at in a while triggers the warning) and basically each time I first add the Local and then CI tells me I broke some older Coq version that we still support. This costs a lot more time than it has to. I cannot keep in my head for all Coq features which exactly is the minimal version they need.

@proux01
Copy link
Contributor Author

proux01 commented Jun 23, 2022

* I don't see any way to take _advantage_ of the coercion (and nobody has claimed there is)

As noted above, in the CI all projects but category-theory are unharmed by the extra coercions and a few project even actually want them. So this statement looks pretty wrong.

Anyway, there is now a specific request for a syntax to make field instances (but not coercions),
so I guess we should proceed as follows:

  • add a new syntax, as offered by @Alizter above in version X (either 8.16 or 8.17, and removing the current warning if X=8.16)
  • update the warning to mention that the new syntax is available since version X
  • in version X+2, remove the deprecation and fix :> to finally mean coercion everywhere

@Zimmi48
Copy link
Member

Zimmi48 commented Jun 23, 2022

Could the warning state that the suggested alternative needs Coq version X to work? The Hint Rewrite thing comes up every few months (some repo I haven't looked at in a while triggers the warning) and basically each time I first add the Local and then CI tells me I broke some older Coq version that we still support. This costs a lot more time than it has to. I cannot keep in my head for all Coq features which exactly is the minimal version they need.

That's a good idea, and this is still time to do it right for the Hint Rewrite warning. Feel free to open a PR.

@Zimmi48
Copy link
Member

Zimmi48 commented Jun 23, 2022

I support @SkySkimmer's suggestion to revert this PR in 8.16 if the new plan is #16224.

@RalfJung
Copy link
Contributor

As noted #15802 (comment), in the CI all projects but category-theory are unharmed by the extra coercions and a few project even actually want them. So this statement looks pretty wrong.

Based on many years of painful experience, I consider all coercions harmful by default until proven otherwise.

Of course, adding a coercion doesn't break a build, but it can still break printing by making goals impossible to interpret. CI wouldn't catch almost any of the things that make coercions painful.

proux01 added a commit to proux01/rocq that referenced this pull request Jun 23, 2022
As discussion in rocq-prover#15802 indicates we
should revert most fo this and rather go for the plan in
rocq-prover#16224 implemented by
rocq-prover#16230
proux01 added a commit to proux01/rocq that referenced this pull request Jun 27, 2022
As discussion in rocq-prover#15802 indicates we
should revert most fo this and rather go for the plan in
rocq-prover#16224 implemented by
rocq-prover#16230
coqbot-app bot added a commit that referenced this pull request Jun 27, 2022
Reviewed-by: Alizter
Ack-by: Zimmi48
Co-authored-by: Alizter <[email protected]>
proux01 added a commit to proux01/rocq that referenced this pull request Jun 30, 2022
As discussion in rocq-prover#15802 indicates we
should revert most fo this and rather go for the plan in
rocq-prover#16224 implemented by
rocq-prover#16230
jwiegley added a commit to jwiegley/category-theory that referenced this pull request Jul 20, 2022
proux01 added a commit to proux01/rocq that referenced this pull request Jan 30, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Jan 30, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Jan 30, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Feb 1, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Feb 2, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Feb 19, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Feb 21, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Sep 10, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Sep 12, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
proux01 added a commit to proux01/rocq that referenced this pull request Sep 19, 2024
…rover#16230

This ends the deprecation phases of
rocq-prover#16230 and
rocq-prover#15802
that introduced :: instead of :> for subclasses in Class declarations.
Now :> means coercion in all record declarations (including typeclasses).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: cleanup Code removal, deprecation, refactorings, etc. kind: fix This fixes a bug or incorrect documentation. kind: usability Not a bug (fix) but a usability issue / improvement, e.g. UI or syntax inconsistencies part: coercions The coercion mechanism. part: records Record types, Structures, etc. part: typeclasses The typeclass mechanism.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants