[GHC] #14331: Overzealous free-floating kind check causes deriving clause to be rejected

GHC ghc-devs at haskell.org
Mon Oct 9 02:40:33 UTC 2017


#14331: Overzealous free-floating kind check causes deriving clause to be rejected
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |
      Resolution:                    |             Keywords:  deriving
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Replying to [comment:2 goldfire]:
 > I assume you really meant
 >
 > {{{#!hs
 > data D = D deriving (forall k a. C (a :: k))
 > }}}
 >
 > but that GHC doesn't quantify `k` the right way.

 I most certainly didn't. (In fact, I've opened a
 [https://ghc.haskell.org/trac/ghc/ticket/14332 separate bug] about the
 fact that you //can// put `forall`s in `deriving` clauses, which horrifies
 me.)

 It's somewhat surprising, but `deriving` clauses can bind type variables
 themselves. Note that this is currently accepted:

 {{{#!hs
 data D = D deriving (C a)
 }}}

 Here, `a` isn't bound by the data type `D`, so it is in fact bound in the
 `deriving` clause. By the same principle, `deriving (C (a :: k))` should
 be allowed, and the free-floating kind check is mistaken to reject it.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14331#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list