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

GHC ghc-devs at haskell.org
Fri Oct 20 13:09:41 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):

 Replying to [comment:33 goldfire]:
 > {{{#!hs
 > class C a
 > data D a = D deriving C
 > }}}
 >
 > We see that `C :: forall k. k -> Constraint`. So we have `ki` = `forall
 k. k -> Constraint`. We then instantiate (note new step, above) to get
 `ki` = `kappa3 -> Constraint`, where `kappa3` is a fresh unification
 variable. Unifying with `kappa -> Constraint` simply sets `kappa :=
 kappa3`. So, `ki2` is really just `kappa3`. This is the special case in
 (d).

 OK. My question is: why do we need to special-case this at all? After all,
 in step (i) we unify the kind of `ty` with `ki2`, and the kind of `ty`
 will always be of the form `... -> Type` by virtue of the kind of `ty`
 coming from a data type. So we achieve the same effect without needing a
 special case at all. (In fact, this is currently what the implementation
 of `TcDeriv` does.)

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


More information about the ghc-tickets mailing list