[GHC] #10141: Kind inference regression in closed type families

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Take the following definition: {{{ type family G (a :: k) where G Int = Bool G Bool = Int G a = a }}} It compiles in 7.8.3, but not in 7.10.1 RC2. This makes me sad. I will fix. (Found by Jan Stolarek.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): This looks bad. Release blocker? I assume so. Say if not. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * resolution: => invalid Comment: This is by design. As I discovered en route to the solution to #9200, the old kind inference for closed type families was bogus. For the type family above, what should the return kind be? `k`, `k2`, and `*` are all viable options. Thus, this type family has no principal kind and should be rejected. Another was of looking at this is that `G` does not have a CUSK. Therefore, its right-hand side must use kind variables uniformly -- which it doesn't, because the first two equations must specialize `k` to `*`. So, closing as invalid. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: closed Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): In this particular case, given the third equation `G a = a`, I'm pretty sure the only possible return kind is `k`, no? But there was that whole long discussion about CUSKs that I didn't really follow, so I take it that in general a closed type family may have no principal kind. I would venture to say though that the error message GHC produces is IMHO not that helpful. In this case the fix is clearly to add a CUSK `type family G (a :: k) :: k where`; could GHC work out when it is appropriate to suggest adding a CUSK? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by jstolarek): * owner: goldfire => * status: closed => new * resolution: invalid => Comment: Replying to [comment:2 goldfire]:
So, closing as invalid. I believe we should create a test case so that any accidental change of semantics does not go unnoticed (like it seems to have between 7.8.3 and 7.10.1?). Richard, I'm re-opening and assigning to you but if you don't have the time please re-assign it to me - I'll take care of that in due time.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by jstolarek): * owner: => goldfire -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): Responding to comment:3: No, the return kind could well be `*`. I'll rewrite with explicit kinds: {{{ type family G (a :: k) :: * where G * Int = Bool G * Bool = Int G * a = a }}} This `G` doesn't really use its kind-polymorphism, but the definition kind checks. However, I think you're right about the suggestion for a CUSK, here and in other cases. And I think it's possible for GHC to have at least some heuristics for when a CUSK is the answer. Specifically, it could include a note about CUSKs in error messages that arise from kind mismatches in non- CUSK right-hand sides. And, yes, this would make for a decent test case. Thanks for the suggestion. I'm very unsure I can get to this by Friday (the next RC release), though! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by goldfire): * priority: highest => normal -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by goldfire): I've added a (not-yet-pushed) test case, but it's hard to see how to improve error messages. The problem is that the place that generates the kind errors is far from where we know whether or not we have a CUSK. I attempted to use `addErrCtxt` to include a note about CUSKs before kind- checking, but this note got appended to lots of errors that are clearly unrelated to CUSKs -- this is the wrong approach. I think the right approach is to somehow record in `TcM` that we're kind-checking a declaration which could potentially have a CUSK but in fact does not and then look there before reporting certain errors. But this is terribly heavy. Perhaps after my branch is merged, a way forward will present itself. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: Kind inference regression in closed type families
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: goldfire
Type: bug | Status: new
Priority: normal | Milestone: 7.12.1
Component: Compiler | Version: 7.10.1-rc2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: None/Unknown | Unknown/Multiple
Blocked By: | Test Case:
Related Tickets: | Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#10141: Kind inference regression in closed type families -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: indexed- Related Tickets: | types/should_fail/T10141 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => indexed-types/should_fail/T10141 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: CUSK mysteries -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_fail/T10141 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Here's an example that I was baffled by. This works {{{ type family F (a :: k) type instance F Maybe = Char }}} But this does not. {{{ type family F (a :: k) where -- = r | r -> a where F Maybe = Char }}} The latter is rejected with {{{ Foo.hs:6:5: error: * Expecting one more argument to `Maybe' Expected kind `k', but `Maybe' has kind `* -> *' * In the first argument of `F', namely `Maybe' In the type family declaration for `F' }}} It is bizarre that one works and the other does not, and I was all ready to open a ticket when Richard said: This is correct behavior. The former has a CUSK, as all open type families have CUSKs with un-annotated kinds defaulting to Type. The latter does not have a CUSK, because the result kind is unknown. You therefore cannot specialize the k variable in the definition of the latter. I can't help feeling that our CUSK story is a bit wonky, so I'm recording it here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: CUSK mysteries -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: TypeFamilies, | TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_fail/T10141 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: TypeFamilies => TypeFamilies, TypeInType -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: CUSK mysteries -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: 8.2.1 Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: TypeFamilies, | TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_fail/T10141 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): If you want `TypeInType` to mean "Richard's bailiwick", that's perhaps convenient. But I'll note that this problem has nothing to do with `-XTypeInType` and exists in 7.10 and perhaps 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: CUSK mysteries -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: TypeFamilies, | TypeInType Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_fail/T10141 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.6.1 => Old description:
Take the following definition:
{{{ type family G (a :: k) where G Int = Bool G Bool = Int G a = a }}}
It compiles in 7.8.3, but not in 7.10.1 RC2. This makes me sad. I will fix.
(Found by Jan Stolarek.)
New description: Take the following definition: {{{#!hs type family G (a :: k) where G Int = Bool G Bool = Int G a = a }}} It compiles in 7.8.3, but not in 7.10.1 RC2. This makes me sad. I will fix. (Found by Jan Stolarek.) -- Comment: Removing milestone as no one is actively looking at this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10141: CUSK mysteries -------------------------------------+------------------------------------- Reporter: goldfire | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1-rc2 Resolution: | Keywords: TypeFamilies, | TypeInType, CUSKs Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: indexed- | types/should_fail/T10141 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: TypeFamilies, TypeInType => TypeFamilies, TypeInType, CUSKs -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10141#comment:21 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC