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
Stable GADT constructor syntax #402
Conversation
While we're tidying up GADTs, there's similar similar-but-different nuances with Pattern signatures - which can also have strictness annotations and/or use record style; oh, also that curious double-
Do we reflect strictness in the type of ordinary H2010 style constructors? We should see the same result from |
Strictness annotations are not part of type signatures regardless of declaration style: ghci> data T = MkT !Int
ghci> :t MkT
MkT :: Int -> T
Pattern signatures definitely deserve some attention, the double |
I think this is on a good, consolidating path |
Note that strictness annotations can be recovered with In the proposal, |
Looks good. I'm in support. Thanks for the very nice write-up. |
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.
It does make sense to me.
d4e1ce0
to
33bf85f
Compare
@nomeata There doesn’t seem to be much discussion around this proposal, so I’d like to submit it to the committee. |
A few clarification questions:
Just a few suggestions for hopefully-quick edits. I plan to recommend acceptance. Thanks! Please ping me here with a mention when this is ready. |
The record syntax allows the As to the other questions, I tried to incorporate the answers into the proposal. Let me know if I missed anything. Thanks! |
@goldfirere Ping. (Apologies, I forgot to include a mention in my previous comment) |
@goldfirere Ping. |
Great. Thanks. I have left a PR at serokell#4 with a tiny wording clarification. I will now recommend acceptance to the committee. |
Hrm. I went to recommend acceptance, but I stumbled. Suppose we have data V a where
MkV :: forall a -> a -> V a That would seem to be accepted by this proposal. But now it seems we need #281 to be able to use I don't think you intended for this to depend on #281, so perhaps you want to say that any constructor with a |
@goldfirere Yes, that was the intent. That is exactly what #81 used to say before it was removed in #393. I think we should simply revert #393 and there will be no problem. But I can also mention it in this proposal, too. |
Iavor asks (on the ghc-steering-committee list) what is the benefit of allowing nested quantifiers. And indeed, the proposal is silent on this point. Can you that? I think the only compelling reason comes when we have |
Richard says
Is it really true that we have to do significant "extra work"? Doesn't the structure of
in which case adding
seems pretty trivial. (I think Richard's claim used to be true, when we stored |
No, there’s no ambiguity. It would be a valid specification, but not as easy to implement. Using a LALR parser (rather than, say, GLR) imposes its own set of constraints. Adding the
The idea is to give more freedom to API authors. For example, in type constructors quantifiers come in arbitrary order:
The idea is to allow the same sort of flexibility in data constructors. I don’t have a concrete use case in mind, but it seems to make the language more regular. |
This part is very not-clear to me, yet is apparently central to the proposal. Try this:
This is way more limited than reality, but it illustrates. I can't see the reduce/reduce conflict. |
I might be missing the core idea behind your code snippet, but it does seem quite similar to what I’ve tried in my branch. My understanding is that source of the problem is that
And
If you’re willing to get your hands dirty, here is my patch: https://gitlab.haskell.org/ghc/ghc/-/commit/32711799397ae76a87ba47b1ba6daa42f94fc965 If you add a |
That may be the case (that storing the parens in the AST is fairly easy). I may have been thinking of the current My desire to drop the parentheses is on theoretical grounds, though, not practical ones: the thing after |
But that argument would apply equally to nested quantifiers, wouldn't it? I'm not sure this line of thinking moves us on much. Maybe we'd be best off simply asking
Incidentally I note that, under the proposal, if you want record field names you can't have nested quantifiers. That seems like an unfortunate fork in the road: you can have nested quantifiers, or named fields, but not both. In the status quo the quantifiers have to be at the front so the issue doesn't arise. TL;DR. I can see merit in this proposal, but little urgency. Meanwhile it's using up our cycles thinking about it. Maybe we should park it (entirely without prejudice) until the needs become more pressing. |
Whether we drop support for parentheses determines how invasive the changes I need to make in order to complete https://gitlab.haskell.org/ghc/ghc/-/issues/18782. Maybe it’s not urgent, but I’ve already sunk quite some time into it (with a few prototypes and writing this proposal), and I intend to finish it, so a resolution would be nice. Just to be clear, keeping support for parentheses simply means more engineering work and complexity in the parser, it’s not a blocker. I remember talking to @goldfirere, and after hearing his ideological argument I figured it to be a good excuse to keep things simpler. Let’s decide whether we want parentheses or not, this will inform my further implementation efforts. |
👋 @goldfirere, accept if there are no objections. |
As proposal shepherd, in an attempt to make forward progress, I propose dropping the part of this proposal about the parentheses, retaining only the bit about quantifiers. My sense is that, with that change, the committee would approve. Furthermore, my sense is that @int-index is not particularly opposed to such a change, so this would seem to make everyone happy. @int-index, please revise the text of the proposal, ping me, and then I will send this back through the committee. Thanks! |
@goldfirere OK, I changed the proposal to retain support for parentheses in prefix-style signatures: data G where
MkG :: !Int -> (!Int -> G) -- OK Note, however, that I did not introduce support for parentheses record-style signatures. As of GHC 9.0, they are rejected: data G a where
MkG :: ({ foo :: Int } -> G a)
Let’s keep it this way, until somebody has a use case for parentheses there. |
yes i think that's fine. Record syntax also does not support nested quantifiers, I note. |
I've prodded the committee to take another look. /remind me to accept in 10 days if there is no further conversation. |
@goldfirere set a reminder for Apr 17th 2021 |
👋 @goldfirere, accept if there is no further conversation. |
This proposal has now been accepted. Thanks, all! |
The proposal has been accepted; the following discussion is mostly of historic interest.
The syntax of GADT constructor declarations is documented in the User's Guide as "subject to change". We propose to fix a couple of issues associated with it and to advertise the resulting syntax as stable (that is, a breaking change to
it would require another proposal).
Rendered