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
Simplify type synonym and type instance scoping #386
base: master
Are you sure you want to change the base?
Conversation
On one hand, this change is very reasonable and I'd like to see it accepted. On the other hand, it introduces an inconsistency with terms, where this continues to be accepted:
I would, by analogy, expect this to be accepted:
But with this proposal it will be rejected since |
proposals/0000-instance-scoping.rst
Outdated
|
||
type family F a :: k | ||
|
||
type instance F Int = Any :: k -> k |
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.
To be clear, the k
in k -> k
is different from the k
in type family F a :: k
, right? Perhaps it'd be a good idea to rename one of these k
s to make that more obvious
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.
done
I ran into something that seems relevant a couple weeks ago, so I'm curious how it would interact with this example: data Relation n m = MkR
type Trans :: forall a b c . Relation a b -> Relation b c -> Relation a c
type family Trans pa pb where
Trans rel MkR = rel -- this type checks but is a partial type family
-- Trans @a @b @c rel MkR = rel -- this would not type check
-- Trans @a @b @b rel MkR = rel -- this would type check Am I understanding correctly that the equation that's not commented out here would not type check under this proposal? If so, I'd very much appreciate that change, since I found it extremely confusing when a type family that looked total judging by the lhss turned out not to be. |
It doesn't introduce such an inconsistency, it merely continues it. When you write But that doesn't happen after the
You might think that would mean
but it doesn't. The outer
We might consider changing that but I didn't think this was the place to do so. |
Co-authored-by: Jakob Brünker <10101851+JakobBruenker@users.noreply.github.com>
Yes you are! I've taken the liberty of adding your example to the proposal. |
I do like seeing these things discussed :). I was thinking we'd get there via #326 + #285 's One of the interesting things to think about is that: t2 = Just (Nothing :: Maybe a) works not by immediately turning into t2 @a = Just (Nothing :: Maybe a) but by becoming t2 = Just (Nothing :: forall a. Maybe a) and then type inference instantiating that. |
Besides some inline comments, there's a typo in the title of this PR itself (s/syononym/synonym/). |
Suggestions from Ryan, thank you Co-authored-by: Ryan Scott <ryan.gl.scott@gmail.com>
I'm in support. This is a nice simplification, enabled by the introduction of new syntax. |
No comments for a month. @nomeata I'd like to submit this to the committee. |
Hmm, I am confused. The proposal says “It depends on proposal #326 (Invisible parameters for declarations).” but #326 is still in draft state. Seems to be too early to submit #386 then? Also, since #386 fixes problems that can’t be fixed without #326, if I am not mistaken, would it make sense to just make them part of #326? |
I'd forgotten that. And John has dropped #326 for lack of time (NOT because it is controversial or unimportant). Bother maybe someone can pick up #326. Maybe even me. Anyone else? I'd be happy to see them combined. |
While modifying some code in GHC related to this proposal, I realized that Change #1 in this proposal doesn't really say what should happen to data family instances. For example, would this be illegal? data family D (a :: k)
data instance D :: Maybe a -> Type That is, you'd instead be expected to write this? data instance D @(Maybe a) :: Maybe a -> Type I think that's the case, based on my understanding of Change #1—the internals of GHC treat the |
Ah yes, very true. It should be absolutely specific. I think that data instances should be distinguishable (from each other) from the argument(s) to the left of the
(The But these are not OK.
|
New proposal to simplify type synonym and type instance declarations
rendered