[GHC] #14331: Overzealous free-floating kind check causes deriving clause to be rejected
GHC
ghc-devs at haskell.org
Fri Oct 13 13:05:49 UTC 2017
#14331: Overzealous free-floating kind check causes deriving clause to be rejected
-------------------------------------+-------------------------------------
Reporter: RyanGlScott | Owner: (none)
Type: bug | Status: merge
Priority: normal | Milestone: 8.2.2
Component: Compiler (Type | Version: 8.2.1
checker) |
Resolution: | Keywords: deriving
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: GHC rejects | Test Case:
valid program | deriving/should_compile/T14331
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
Huh? That is not what I would have expected at all. I would have expected:
{{{#!hs
class C {k1 k2} (a :: k1) (b :: k2)
data D {k3} (r :: k3) = D
instance forall k1 (a :: k1). C a (D a) where ...
}}}
In other words, you should unify `r` with `a`. After all, the `a` in `data
D a = D deriving (C (a :: k))` scopes over the data type, not the
`deriving` clause!
Now if you had chosen to use a different scoping with `data D a = D
deriving (forall (a :: k). C a)`, //then// I could see the instance being
derived that you suggested. But I don't think users would expect that
behavior to be the default (that is, in lieu of explicit `forall`s on a
`deriving` clause, one should assume that the user-written type variables
are bound by the data type if they appear in the `<tvbs>` in `data D
<tvbs>`).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14331#comment:14>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list