-
Notifications
You must be signed in to change notification settings - Fork 269
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
Resurrect PatternSignatures #119
Conversation
Here is a user who was confused by having to use |
The proposal I'm really looking for is the one that makes |
@JacquesCarette I think anything that modifies "Official Haskell" is going to have to be wrapped into the next Haskell Report. I don't know how that process is going. I do agree that would be awesome. |
I believe that's outside the scope of this repository, that's really a
haskell prime prosoal.
…On Fri, 6 Apr 2018, 7:33 pm Jacques Carette, ***@***.***> wrote:
The proposal I'm really looking for is the one that makes
ScopedTypeVariables an official part of Haskell the language rather than
some language option to turn on. Where would that one be?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#119 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABRjiy5j2ojC5BBQBE5ADFcIrOzY9gkks5tl7TogaJpZM4TKQc9>
.
|
That’s correct. It might be that the Haskell Prime committee will consider |
Right -- https://prime.haskell.org/ticket/67 seems to be the ticket. |
That's actually the reason for my conservatism on this too. My feeling is this is all part of a class of "obviously these should be the default" extensions and having more granularity about them seems to be swimming against the stream, since it would be nicer to not have to add any of them at all :-) |
I am all for having both by default! But this discussion here is “what world to we want after the next GHC release”, not “what world do we want if Haskell prime happens”, which maybe much further in the future. Don’t let perfect be the enemy of good. |
@nomeata Good point. +1 from me on this, for that reason. |
Wait? Is this the ghc-proposals tracker? I must be lost :-P |
Is there somewhere a proposal for |
@tomjaguarpaw yes, #92 |
Thanks @nomeata, it's not clear to me whether you're just complaining For myself, I find it far too confusing to give local signatures inside If the complaint is just about a misleading name; well ghc extensions have lots of them. Perhaps "confused users" just have to get used to it? |
Mostly the former.
Correct, everybody who uses
That’s what I thought 5 years ago, or so. But I still am regularly annoyed by it, so that does not seem to work :-) |
I think |
Does anyone know the reason that |
Let me be the dissenting voice. I always want |
@treeowl Let me see if I understand you correctly. You are against an extension to enable syntax like let x :: Int = 0 because you currently use the presence of such syntax to deduce that |
@tomjaguarpaw, it's not that I do so intentionally. But I probably do so subconsciously, so I predict this change would make me more likely to get confused. I'm not actually dead-set against the proposal, but I do think the proposal text should include the potential for confusion in the appropriate section. I'd also like to see more discussion of how we can get the power we want from |
The "proposed spec" says
What does that mean? Suppose I have with
is that allowed or not-allowed? Perhaps it is allowed, but does not bring |
It’s not allowed. I clarified the proposal. |
Why not? It seems like a free design choice to allow or not-allow. And not-allowing means you simply can't use a pattern signature in places you might really want to. |
…tures" and explain why This reverts commit fee0c10.
Changed my mind :-] For one target audience of this extensions (confused beginners who want to add type signatures to every subterm, whether left or right of the
but allow
I feel that rejecting a program with a message that essentially says “you are doing something non-trivial, please use |
I believe that you are proposing: with My judgement differs, but it's just an opinion. It would be good to hear from others, please. What about this
Is that OK? Because that pattern signature does have some (invisible) kind variables. The real type of
So is that allowed or not allowed? If we didn't have the no-free-var restriction, the question doesn't arise. |
It sounds to me like the best way forward is to treat pattern annotations exactly like expression annotations, where any type variables are locally bound by a forall. This effectively renders type variables in patterns useless, but it's at least a consistent place to stand. This is option (1) from #119 (comment) |
Hence my phrasing: “Does not bind type variables”. It is a pure renamer check: Is there a type variable in the pattern that is not already in scope? Then the program needs (I guess without
I see the consistency, but it would be incompatible with But still thanks for your point, because the contention only supports the plan to pass such programs right back to the user for clarification :-) |
My concern is magnifying. The proposed extension offers very little power, and there's a tremendous amount of disagreement about what exactly it should mean. If this gets added, someone will have to work out how each new (and more powerful) feature needs to interact with it. My general thinking is that having an extension like this that supports completely monomorphic signatures (no type variables) should be acceptable. Beginners will be able to use that without any trouble, and everyone else can just ignore it. Once type variables come in, my vote goes from "don't care much" to "please don't". |
(I assume you mean with I'm inclined to agree with David -- it's really not worth the effort to make the distinction between these two extensions. |
David says
which is what the proposal currently says! Well, not quite: it says “binds no type variables“, which amounts to, and could be rephrased as, ”has no free type variables”. This intentionally allows
But I assume this part is uncontroversial. Are we in agreement that |
No -- I argue that But that's just my opinion. |
I am by now pretty much baffled by what it is that's proposed. I can see there's no consensus. Does the write-up at least represent @nomeata's current thinking? Restricting to only monomorphic signatures (no type variables except for If we're worried about "confused beginners" who want to understand the type for every sub-term, I would expect at least some of those sub-terms might be polymorphic (so what's proposed can't help them?); and/or they'd like to put wildcards Then I'm looking at option 1 above
[ BTW re "signature on the RHS" I don't follow why a explicit take 1. with @goldfirere's comment
So we want any
To avoid confusion with what happens under And I think the explicit
Note there might not be an explicit signature separately given for Re @simonpj's last comment
I'm afraid I've forgotten (if I ever knew) what is the precise semantics for A(nother) small plea arising from "confused beginners": they learn that all signatures in effect have a With
|
The proposal doesn’t seem to receive support in the committee anyways, so this discussion somewhat futile now, but I am happy to address some your points (if I understand them correctly, I am notsure) Because of
I want to forbid pattern signatures that have free type variables, and have the compiler tell the user “Either close the type signature with If |
Thanks @nomeata. As the proposal currently stands, I'd agree it has low power to weight. I was looking for a way to give more power (and particularly thinking of helping "confused beginners").
One of your complaints was that
I think I've steered a course between Scylla and Charybdis: this is not status quo, because I suggest binding fresh |
Oh, you still can; you just have to put in the
|
? Your option 1. above shows If we're thinking about "confused beginners", putting explicit Then it appears I've been labouring under a misunderstanding. Thank you for pointing this out:
OK. Then I'm proposing that bit of What's confused me is the User Guide 10.16.4 saying "pattern type signatures are not implicitly generalised. The pattern in a pattern binding may only mention type variables that are already in scope." It goes on to discuss binding for existentials: "in this situation (and only then)" is just false. "If all this seems a little odd, ..." that I quote above is just false. Neither the User Guide nor your proposal have any dead-simple examples like:
And your comment -- my
Yes. Hooray! Where is that behaviour described? And why wouldn't you want it included under So I'm proposing [Note **] I'm getting weirded out: that ADDIT: Heh, heh. In fact this technique of putting |
941b416
to
97cdab6
Compare
This proposal was rejected for insufficient merit. |
Just in case anybody ever wanders back here: I just wanted this feature. I'm writing a Haskell application which I will use in a class that teaches a very limited amount of Haskell. For it to actually get work done, I sadly need a stack of monad transformers. I won't be requiring students to edit that code, but I want some guidelines for the intrepid. At one point, I have
Even I go cross-eyed on that line. So I modified it to be
Much better -- now I know what I'm working with. But silly GHC won't accept this without I'm not trying to reverse a decision, but just laying out an additional use case I just ran into for posterity. |
Yeah … precisely my thinking. Maybe we can sneak this in as part of a more general splitting of |
... or persuade that |
That was my other motivation: By giving the extension a name in the first place we can talk about it on the way to a new standard. |
Rendered