[GHC] #8865: Cannot derive well-kinded instance of form ‘Category

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------+---------------------------------------------- Reporter: | Owner: adinapoli | Status: new Type: bug | Milestone: 7.8.1 Priority: normal | Version: 7.8.1-rc2 Component: Compiler | Operating System: MacOS X Keywords: | Type of failure: GHC rejects valid program Architecture: x86_64 | Test Case: (amd64) | Blocking: Difficulty: Unknown | Blocked By: | Related Tickets: | ----------------------------+---------------------------------------------- Hello everyone, sorry if this was already reported somewhere. I'm playing with GHC 7.8.1 RC2 and I'm updating hsenv to support GHC 7.8. This is a real code snippet, which was compiling fine in GHC 7.6.x {{{ newtype ArgArrow a b = ArgArrow (StaticArrowT KnownArgs (Kleisli (ReaderT Args IO)) a b) deriving (Category, Arrow, ArrowChoice) }}} but that yields the following in GHC 7.8.1-RC2 {{{ Cannot derive well-kinded instance of form ‘Category (ArgArrow ...)’ Class ‘Category’ expects an argument of kind ‘k -> k -> *’ In the newtype declaration for ‘ArgArrow’ }}} This might be related to the new feature of GHC 7.8, namely "kind variables" (you get the idea, even if the name is not 100% accurate). To make the code compile I had to enable {{{ StandaloneDeriving }}} and write the following: {{{ newtype ArgArrow a b = ArgArrow (StaticArrowT KnownArgs (Kleisli (ReaderT Args IO)) a b) deriving (Arrow, ArrowChoice) deriving instance Category ArgArrow }}} Is this by design or is a genuine bug? Thanks! Alfredo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by simonpj): I'd like to reproduce this, but need definition for `StaticArrowT`, `KnownArgs` etc. Can you add those definitions to the module, and give the complete source code for a module that shows the problem? Ideally, not depending on other libraries. Thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by simonpj): Oh, don't worry, I can reproduce it with {{{ {-# LANGUAGE GeneralizedNewtypeDeriving #-} module T8865 where import Control.Category newtype T a b = MkT (Either a b) deriving( Category ) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by adinapoli): Just as well :) If you need the full source, just out of curiosity, it can be found, together with all the definitions, here: https://github.com/tmhedberg/hsenv -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category
----------------------------------------------+----------------------------
Reporter: adinapoli | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version:
Resolution: | 7.8.1-rc2
Operating System: MacOS X | Keywords:
Type of failure: GHC rejects valid program | Architecture: x86_64
Test Case: | (amd64)
Blocking: | Difficulty: Unknown
| Blocked By:
| Related Tickets:
----------------------------------------------+----------------------------
Comment (by Simon Peyton Jones

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: fixed | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Changes (by simonpj): * status: new => closed * resolution: => fixed Comment: Fairly easy fix, fortunately. Thank you for reporting. It should be easy to merge, but it's a bit of a corner case, and we are really far into the 7.8 cycle, so it might be better not to Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: fixed | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by adinapoli): Glad I was useful. Happy to do my part on GHC, even if for some minor bug reporting :) Alfredo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: fixed | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by thoughtpolice): I'm somewhat inclined to think we actually should merge this. At the time the proposal to make `Category` PolyKinded was made, one of the nice parts was that it is essentially an invisible change to already existing code. In some sense I might argue that this is a regression, because while it involves a small 'change' that did not exist prior, it does cause GND over Category to fail in the wild, where it did not before. OTOH, I'm not sure how common the case of using GND to derive Category instances is - this is certainly the first time I've seen it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: fixed | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by thoughtpolice): Oh, and really, Category isn't necessarily the only thing affected - per the test case, I would actually expect *anything* with a polymorphic kind inferred by `PolyKinds` being enabled will no longer be GND-able, which is quite a shame it would seem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: closed Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: fixed | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by carter): the Pattern Arrows package used for purescript hits this exact same issue too. https://github.com/paf31/pattern-arrows {{{ [1 of 1] Compiling Control.PatternArrows ( src/Control/PatternArrows.hs, dist/build/Control/PatternArrows.o ) src/Control/PatternArrows.hs:32:92: Cannot derive well-kinded instance of form ‘C.Category (Pattern ...)’ Class ‘C.Category’ expects an argument of kind ‘k -> k -> *’ In the newtype declaration for ‘Pattern’ }}} can i assume that the fix will be merged into 7.8 branch too? :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: fixed | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Changes (by simonpj): * status: closed => merge Comment: Yes, I think we should merge. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category ----------------------------------------------+---------------------------- Reporter: adinapoli | Owner: Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: fixed | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: x86_64 Test Case: | (amd64) Blocking: | Difficulty: Unknown | Blocked By: | Related Tickets: ----------------------------------------------+---------------------------- Comment (by Lemming): Just encountered this problem myself. It can be reproduced with the simple module: {{{ {-# LANGUAGE GeneralizedNewtypeDeriving #-} import Control.Arrow (Arrow) import Control.Category (Category) newtype Fails a b = Fails (a -> b) deriving (Category, Arrow) newtype Works a b = Works (a -> b) deriving (Arrow) instance Category Works where }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category -------------------------------------------------+------------------------- Reporter: adinapoli | Owner: Type: bug | Status: merge Priority: normal | Milestone: 7.8.1 Component: Compiler | Version: Resolution: fixed | 7.8.1-rc2 Operating System: MacOS X | Keywords: Type of failure: GHC rejects valid program | Architecture: Test Case: | x86_64 (amd64) deriving/should_compile/T8865 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: -------------------------------------------------+------------------------- Changes (by simonpj): * testcase: => deriving/should_compile/T8865 Comment: Yes, works in HEAD, and will do in 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category -------------------------------------------------+------------------------- Reporter: adinapoli | Owner: Type: bug | Status: Priority: normal | closed Component: Compiler | Milestone: 7.8.1 Resolution: fixed | Version: Operating System: MacOS X | 7.8.1-rc2 Type of failure: GHC rejects valid program | Keywords: Test Case: | Architecture: deriving/should_compile/T8865 | x86_64 (amd64) Blocking: | Difficulty: | Unknown | Blocked By: | Related Tickets: -------------------------------------------------+------------------------- Changes (by thoughtpolice): * status: merge => closed Comment: Merged in 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8865#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8865: Cannot derive well-kinded instance of form ‘Category
-------------------------------------+-------------------------------------
Reporter: adinapoli | Owner:
Type: bug | Status: closed
Priority: normal | Milestone: 7.8.1
Component: Compiler | Version: 7.8.1-rc2
Resolution: fixed | Keywords:
Operating System: MacOS X | Architecture: x86_64 (amd64)
Type of failure: GHC rejects | Test Case:
valid program | deriving/should_compile/T8865
Blocked By: | Blocking:
Related Tickets: |
-------------------------------------+-------------------------------------
Comment (by Ryan Scott
participants (1)
-
GHC