[GHC] #9968: DeriveAnyClass fails on multi-parameter type classes

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- When I say {{{ {-# LANGUAGE DeriveAnyClass, MultiParamTypeClasses #-} module Bug where class C a b data X deriving (C Int) }}} and load that into GHCi, I see this: {{{ *Main> :load "/Users/rae/temp/DeriveAny.hs" [1 of 1] Compiling Bug ( /Users/rae/temp/DeriveAny.hs, interpreted ) Var/Type length mismatch: [b_a2YW] [] Var/Type length mismatch: [b_a2YW] [] Ok, modules loaded: Bug. *Bug> :info C class C a b -- Defined at /Users/rae/temp/DeriveAny.hs:5:1 instance C X -- Defined at /Users/rae/temp/DeriveAny.hs:7:13 }}} It seems my `Int` parameter to `C` is being dropped. I don't believe I have a debug build in this example, so that debugging output is shipping. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc1 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 simonpj): * owner: => dreixel * priority: normal => highest Comment: Pedro this looks like your territory. Might you look? It's an outright bug. Thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: highest | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9821 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by dreixel): * related: => #9821 Comment: Yes, this is probably related to #9821. I can look into it next week. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9821 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * priority: highest => high -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9821 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by dreixel): Simon, could you give me some help with this? I was hoping it would be easy to just reuse the infrastructure for newtype deriving here. Should I follow the structure of the `EarlyDerivSpec` generated by the first branch of `mkNewTypeEqn`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9821 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): Branch `wip/T9968`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #9821 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): FYI Pedro is actively working on this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9821 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by osa1): I managed to get a panic out of this: (this is with GHC 7.10.2) {{{ ➜ trac9968 cat Bug.hs {-# LANGUAGE DeriveAnyClass, MultiParamTypeClasses, FunctionalDependencies #-} module Bug where class C a b where showFirst :: (a, b) -> String showSecond :: (a, b) -> String data X deriving (C Bool) main :: IO () main = putStrLn "ok" ➜ trac9968 runhaskell Bug.hs Var/Type length mismatch: [b_alK] [] Var/Type length mismatch: [b_alK] [] Var/Type length mismatch: [b_alK] [] Var/Type length mismatch: [b_alK] [] ghc: panic! (the 'impossible' happened) (GHC version 7.10.2 for x86_64-unknown-linux): funResultTy forall b_alK. C X b_alK => (X, b_alK) -> String Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} A question about how `deriving` syntax supposed to work: Let's say we have {{{ class C a b data X }}} as in the example above. We can do `deriving (C Bool)`, which implements an instance for `C Bool X` but if I want to derive `C X Bool`, is there a way to do that? Currently if I try to do `deriving (C X Bool)` or `deriving (C Bool X)` I'm getting this error: {{{ ➜ trac9968 runhaskell Bug.hs Bug.hs:10:13: Expected kind ‘k0 -> GHC.Prim.Constraint’, but ‘C Bool X’ has kind ‘GHC.Prim.Constraint’ In the data declaration for ‘X’ }}} Which is clear enough but I'm wondering if there are any workarounds to make `deriving (C X Bool)` work. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9821 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by osa1): * cc: osa1 (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9821 | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): I think it's best to keep the simple rule: `data X = ... deriving (..., c, ...)` means to derive `c X` (here `c` is an application of a class constructor to zero or more types). After all if you want something else like `C X Bool` then you can express that with a standalone deriving declaration `deriving instance C X Bool`. Or in this case just write an empty instance, it's shorter :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9821 | Differential Rev(s): -------------------------------------+------------------------------------- Changes (by simonpj): * cc: kosmikus (added) Comment: Adding Andres, the king of generics. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #9821 | Differential Rev(s): -------------------------------------+------------------------------------- Comment (by simonpj): See also #10938 for another example of this bug -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: dreixel
Type: bug | Status: new
Priority: high | Milestone: 8.0.1
Component: Compiler | Version: 7.10.1-rc1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #9821 | Differential Rev(s):
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#9968: DeriveAnyClass fails on multi-parameter type classes
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: dreixel
Type: bug | Status: new
Priority: high | Milestone: 8.0.1
Component: Compiler | Version: 7.10.1-rc1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #9821 | Differential Rev(s):
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | deriving/should_compile/T9968, | should_fail/T9968a Blocked By: | Blocking: Related Tickets: #9821 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * testcase: => deriving/should_compile/T9968, should_fail/T9968a * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9968: DeriveAnyClass fails on multi-parameter type classes -------------------------------------+------------------------------------- Reporter: goldfire | Owner: dreixel Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Compiler | Version: 7.10.1-rc1 Resolution: fixed | Keywords: Generics Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | deriving/should_compile/T9968, | should_fail/T9968a Blocked By: | Blocking: Related Tickets: #9821 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * keywords: => Generics -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9968#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC