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
Prefix form for MkSolo# (amendment of #475: Non-punning list and tuple syntax) #638
Conversation
It seems like a definite oversight to me, I can't find any arguments for not having |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to fix this. But I'm a little worried about programmer confusion here. I think that the pretty-printer should continue to print applied unary tuples using mixfix syntax. Is there ever a case where we have to print an un-applied constructor where the user didn't write this? If not, then no problem. If there is, we should be careful in an error message to tell the user of the relationship between MkSolo# x
and (# x #)
.
proposals/0475-tuple-syntax.rst
Outdated
#. The name of the data constructor for unboxed 1-tuples is ``MkSolo#`` rather | ||
than ``(# #)`` to distinguish it from the data constructor for 0-tuples. | ||
The ambiguity only arises when the name is used unapplied. | ||
When applied to an argument, ``MkSolo# a`` can be written and pretty-printed as ``(# a #)``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"can be" or "is" (at least for printing)? That is, I would want the prefix MkSolo#
to be a rare sight for programmers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the text to reflect this preference
646e1fb
to
e30f757
Compare
It was not my intent to change this. GHC should indeed continue to print
I've only seen it happen in pretty-printed Core where left-hand sides of |
@adamgundry Let's submit this for committee consideration. |
Reading this amendment makes me wonder:
Concerning (3), an alternative could be to stick with
rather than
Concerning (4), we are free to invent different canonical names for our unit data constructors. Rather than I am not advocating strongly here for any one path. This is detail stuff. But we will be stuck with this forever; I hadn't seen the non-uniformity so clearly before; and uniformity is a virtue. |
Compelling idea. Note however that the new names are already in GHC 9.8 |
@simonpj We have already transitioned to I'm not opposed to other names in principle, though I don't believe Regarding the canonical names, i.e. the choice between |
FWIW the tuple printing logic is as specialized as it can get already |
What about class instances? Say I want to declare
Do I have to turn on |
As I say, I'm asking, not recommending. It doesn't look as if the case for change (wrt the proposal) is compelling. |
This proposed amendment has been accepted. The alternative described by Simon is left for a future amendment to #475. Thanks for your hard work @int-index! |
This amendment to proposal #475 has been accepted; the following discussion is mostly of historic interest.
At the moment, the proposal defines
Alright, so what are the prefix forms of those constructors? The data constructor of
Unit#
is(# #)
, and the data constructor ofSolo#
is... also(# #)
! This is an ambiguity.We can resolve this ambiguity by renaming the data constructor of
Solo#
toMkSolo#
, retaining the mixfix(# a #)
syntax of course.Please review: @goldfirere, @tek