[GHC] #15810: Kind inference error in classes

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This is rejected today, but it shouldn't be: {{{#!hs class C a where meth :: Proxy (a :: k) }}} It's the kind signature that kills it. Expected solution: change `tcImplicitTKBndrs` to `kcImplicitTKBndrs` in `kcHsKindSig`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): That change does indeed appear to fix the issue when I tried it. Only one test case seems to regress with this change: {{{#!diff diff -uw "polykinds/T7328.run/T7328.stderr.normalised" "polykinds/T7328.run/T7328.comp.stderr.normalised" --- polykinds/T7328.run/T7328.stderr.normalised 2018-11-11 15:15:40.843707612 -0500 +++ polykinds/T7328.run/T7328.comp.stderr.normalised 2018-11-11 15:15:40.843707612 -0500 @@ -1,6 +1,6 @@ T7328.hs:8:34: - Occurs check: cannot construct the infinite kind: k1 ~ k0 -> k1 + Occurs check: cannot construct the infinite kind: k00 ~ k0 -> k00 In the first argument of ‘Foo’, namely ‘f’ In the first argument of ‘Proxy’, namely ‘(Foo f)’ In the type signature: foo :: a ~ f i => Proxy (Foo f) }}} I can't tell if this is expected behavior or not. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Very strange output. But I wouldn't put much effort here. Simon has a Big Patch (Phab:D5305) that may include this fix, as it's utterly rewriting all the functions involved in this patch. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5305 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * differential: => Phab:D5305 Comment: See comment:2:ticket:15809. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5305 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): Hmph. Given {{{ class C a where meth :: Proxy (a :: k) }}} where is the implicit forall for that `k`? Currently it's quantifed at the `::`, thus: {{{ class C a where meth :: forall k. Proxy (a :: k) }}} And indeed that is ill-typed, and elicits {{{ T15810.hs:9:18: error: • Expected kind ‘k’, but ‘a’ has kind ‘k0’ • In the first argument of ‘Proxy’, namely ‘(a :: k)’ In the type signature: meth :: Proxy (a :: k) }}} If you brought `k` into scope further out it'd be fine {{{ class C a where meth :: Proxy (a :: k) }}} In short I say this is not a bug. Do you disagree? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5305 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Did you mean for the last example in comment:4 to be different than the first? I presume you did. We allow {{{#!hs data T a where MkT :: T (a :: k) }}} today. That `k` is also locally quantified. I can see the argument for rejecting the original program, but it's inconsistent to reject that while accepting the datatype equivalent. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5305 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
Did you mean for the last example in comment:4 to be different than the first?
Yes I did. Now fixed. Data type decls (in GADT style) are different to class decls. In a data type decl the type variables from the head do not scope over the individual data con signatures. So your example really reads {{{ data T a wher MkT :: forall k a. T (a :: k) }}} and the following would be equally acceptable {{{ data T a wher MkT :: T (b :: k) }}} But with classes the type variables from the class header do indeed scope over the method declarations. So they are already inconsistent in that sense. I still say "no bug here" :-). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5305 Wiki Page: | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => closed * resolution: => invalid Comment: Hmmph. Fine, you win. :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5305 Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I hope that means "I reluctantly agree that this is not a bug" rather than I've just worn you out :-)! I'd be happy with a better solution. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15810: Kind inference error in classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 8.6.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5305 Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): Yes, you got it. I agree with your analysis. But it all makes me wish we had a more regular syntax for these declarations. Between classes, datatypes (with two syntaxes), and type families (both associated and not), we just have a veritable zoo of special cases. This is not a problem to solved right now, right here, though. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15810#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC