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
Amend #448 so -XPatternSignatures
does not include implicit bindings
#608
Amend #448 so -XPatternSignatures
does not include implicit bindings
#608
Conversation
Mistakenly included on this branch
This would essentially be #119, right? |
Yes! |
I agree, so thank you for that. Never the less I'm having a hard time reconnecting all the dots to follow which particular convoluted position we've reached. Bear with me ...
This example appears to be ill-typed. (I'm being pedantic, but since this is one in a series of mods to a mod to a reintroduced extension, I feel pedantry is the point of the exercise.) I think we should have
Also I'm not happy with that form of
Yes, but this never caused me conceptual difficulties. It's only with |
I hope you don't mind @simonpj; I think these edits in no way changed the spirit of what you were saying.
The type errors are now fixed. Thanks for pointing them out to me. They are original in #523 (comment) but i hope @simonpj doesn't mind editorializing the quote to fix them.
What should: f (x :: a) = undefined
where
g (y :: a) = undefined With In my opinion, the interpretation in this amended proposal is the only one that is both unsurprising and doesn't require "nervously looking around" for outer binders, as you put it well. |
@nomeata I would like to submit to the committee! |
Good question! And I agree needs a little 'looking around' -- but only a little. I'll try a variation
This compiles, infers Now try (in a Haskell that supports not only
This compiles, infers I can change that top line to So what worries me with this proposal is you're taking away the ability for Complexifying because why are you forcing me to distinguish a binding from a usage in types? Types don't work like terms. Types work by unification not evaluation (beta reduction). Unification means if I have an |
(This is probably a q for some other proposal in this whirl but ...) Are we sure in patterns we can distinguish To introduced tyvars appearing nested inside constructors I can't go
which seems long-winded. |
Another way to mentalise |
I don't think that is true (there is a mix of unification and special-cased "bidirectional typechecking" methods going on, and with GHC Issue #23639 fixed there will be even more). Moreover, this philosophy --- types are not like terms, the scoping / name resolution of type need not be explicit / types should not be thought of as substitution is decidedly not the philosophy of #448. I don't expect you to start liking this stuff when you didn't before, but I also don't think an amendment proposal like this one is the right place to re-litigate these issues. As an aside, let me add that "types working like beta reduction" isn't just some fancy Martin Löf thing, it is also a System F thing. My strong desire to see parsing and renaming for types and terms work the same way can thus be departed from any Dependent Haskell notions.
Yes that was cleaned up and properly specified by @int-index for a few releases now. |
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.
Thanks very much for this @Ericson2314! I supported this idea five years ago and I'm still strongly in favour.
@goldfirere Had a chance to read this one yet? (Sorry I didn't think to mention this in person at ICFP.) I recall, hopefully correctly, from the other threads that you also wanted this, but were worried others on the steering commit did not, but then they in fact were OK with this. |
Sorry for losing track of this one. I'm in support of having a mechanism to forbid binding type variables in pattern signatures, but I disagree with the specifics here: with this amendment, And, as far as I can see, the behavior specified in this proposal is already available, via To be clear, I agree that we should support Haskellers who want to prevent their pattern signatures from binding variables. But I argue that the existing #448 already accomplishes this goal and would need to be convinced that the status quo is somehow insufficient before recommending acceptance. (I don't mean to just unilaterally block this proposal, and so I'm happy to forward to the committee with a "reject" recommendation; perhaps others will disagree with me.) |
@goldfirere The most notable is the interaction with other features: For example, having contextual bindings like this breaks x = 1
f (_ :: x) = 1 -- is 'x' a bind or a use? Can't change based on warnings alone! There is a no-go situation where either this or that must be an extension, we cannot have both of them being warnings. I recall there was much more worry about punning/single namespace functionality "forking the language", whereas no one seemed to have any particular love for pattern signature binds, so it seems more prudent to make this side the extension case, and keep that side mere warnings. This an other interactions was detailed in a the much larger #532, but I had pulled them out because I thought this change was uncontroversial. I suppose I can add them back if you like. |
I'm afraid I still don't get it. Even with the proposed amendment, the Already, we're saying that you're more future-compatible with dependent types if you have Note that the situation with |
@goldfire Sorry let me be more explicit:
|
The extension version of I think most people agree shadowing is of dubious utility (unless someone is trying to teach how substitution works), so leaving Whereas in response to the shadowing issues I think I can say "just don't shadow", in response to the pattern signature bind issues I don't think I can say "just don't try to use that variable there". |
I am a huge fan of single-namespace Haskell. But despite your kind re-explanations, I still don't see how this proposal gets us closer to that goal. You say "the single namespace user [is] unable to use the term-namespace-bound x in a pattern signature (because the implicit bind gets in the way)." How does this proposal change that? It sounds to me as if you're imagining some future |
Today there are two choices:
The point of this proposal is to take the opportunity of the newly reintroduced, yet-unimplemented
I am not imagining a I don't think we need to do anything about about |
OK @simonpj I've reworked this:
|
Thanks. I found the new 3.2.2 hard to follow. But I am content with the actual payload in 3.5. |
I think you mean @goldfirere? |
Great, and also I am happy to reword 3.2.2 too; I didn't think I had yet found the wording to be clear either. |
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.
Just some typos, etc. Nothing interesting in the review.
OK. I'll recommend acceptance. Though I've come to think that we're fighting the wrong battle here, in extension shuffling. #628 paves a different way forward. Yet those ideas should not stop others from making progress. |
Great! And to be clear, I would be very happy to someday reformulate this stuff in a post-#628 approach. The gist is that I am hoping new editions going forward can have as little implicit binding as possible, and no pattern signature binds in particular (as But making |
I see there was a lot of discussion of this on the mailing list https://mail.haskell.org/pipermail/ghc-steering-committee/2024-January/thread.html I just want to answer a few things: Deprecating
|
Thanks @adamgundry for relaying my last post to the list :) @simonpj writes
I think that proposal was to keep If we can change |
Hey just checking it looked like a positive consensus was being reached on the mailing list end of Jan / beginning of Feb, but was there ever a final vote? |
Without much enthusiasm from the committee, but with a small leaning in favor, this proposal is now accepted. |
It does look like there's a build failure. @Ericson2314 do you want to investigate this before we merge? |
The readthedocs failure can be ignored, or probably be solved by merging |
The reason of readthedocs failure - this git-fork is not updated for too long, last update was before Feb 2024. |
Hooray! Very happy this is accepted :). Thanks everyone. I am now back from a trip, and just pushed a merge with master. I'll watch this to make sure CI passes. |
OK good, it passes now! |
The proposal has been accepted; the following discussion is mostly of historic interest.
2nd in a series of #448 amendments, following up from #604, building towards #532
This proposal scales back #448 's reintroduced
-XPatternSignatures
so that it does not include pattern signature bindings. Pattern signature binds have multiple drawbacks that pattern signatures themselves do not have, so it makes sense to want them to be enabled separately. Pattern signature bindings are instead are enabled by-XScopedTypeVariables
, which is unchanged.This unblocks https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10385 by @s-and-witch. Unlike #604 this does not effect GHC 9.8, so it isn't so critically urgent to resolve.
(Instead of a rendered link, go to the Files Changed tab and toggle the rich text diff option. Rending the whole proposal is not that useful when this is a small change to a much larger proposal.)