-
Notifications
You must be signed in to change notification settings - Fork 366
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
Remove =
sugar for propositional Equality
#3211
Comments
What I always liked about
I don't feel myself a newcomer, but I personally still find Another downside of You considered the only alternative of doing nothing. In the motivation section (along with unique presedence of |
I also like this, and experimented with the compiler to make
Not a problem with the new fixity namespace features. The compiler can detect if there is a conflicting fixity and generate the appropriate program if necessary. In this instance it would mean hiding the built-in fixity for
I think that's a great idea, however it does not really address the upgrade path problem which is the main body of this proposal. We would still need to provide a way to upgrade without breaking existing code-bases. Like mentionned at the end: we don't really have to, but that's the essence of this proposal, to do something nice while learning something on the way there. I know we have a lot of issues right know with code synthesis and this would be a great time to review the infrastructure around it. |
I can see it as being a drop-in idea for the end-goal with your proposed solution for migration still being applicable. I think I like the idea of The desugar code action initially seemed of arguable use to me outside of this very specific migration need, but the more I think on it the more I can imagine situations where lifting a I saved this for last because it is a bit "sunk-cost-ty" but I'm in favor of past work that served to differentiate e.g. assignment from equality by introducing |
Summary
Currently, to use built-in propositional equality, we can use the
=
symbol between two expression to stand for either homogenous equality(===)
to heterogenous equality(~=~)
. The proposal is to provide and upgrade path towards the removal of=
.Motivation
=
as a symbol for propositional equality has the benefit of being easy to type and easy to read for newcomers. However, the benefits stop here. Because it overloads both~=~
and===
it can create situations where an error occurs because the compiler disambiguates into heterogenous equality, when homogenous equality was needed. What is more, the presence of this symbol makes the syntax quite a lot more difficult to parse since it has to be disambiguated from=
as a clause.The proposal
The main proposal is actually not about removing special syntax for
=
but to provide an upgrade path for existing packages making use of=
so that we can avoid breakage. The traditional way to achieve this is to emit a warning for the deprecated feature, and to change this warning into an error in a subsequent version. This would be perfect if not for the fact that most users (and build systems) simply ignore warnings.To remedy this, I suggest we selectively update the content of a compiled file to insert the correct operator, either
~=~
or===
. There are multiple strategies to do that, what I suggest is that we introduce a editor-action to replace the content of an expression by its compiled-tree version, so that users can easily desugar=
into either===
or~=~
1. Once we have this, we can automatically replace the content of a file, when it's compiled, to the desugared form of=
. Because we do not want this to interfere with interactive editing, it should not be run every time we typecheck the file. However, if we can compile a file with--build
, run the code-action on every instance of=
and compile the file again, in a way that we obtain the same typechecked tree, we could simply replace the file in-place with the new syntax.Alternatives considered
Realistically there is only one alternative: Do nothing. Which is what we've been doing this entire time! Arguably, there is not much urgency for this proposal, but it would be a good academic exercise to deploy, at scale, our code-synthesis tools.
Conclusion
If we agree that we do need to remove
=
, all this work is more of an academic exercise, rather than an absolute necessity. This proposal is also quite brute force, and there might be better ways to do this, but for such a frivolous project, perfect is the enemy of good. And placing more sophisticated expectations on a translation solution might be enough to ensure it never gets done.Footnotes
This feature has potentially other uses when exposed to the user(desugar
if_then_else
, desugar lambda case, desugarwith
), but I do not wish to examine them further in this document, nor is it the goal of this project. ↩The text was updated successfully, but these errors were encountered: