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

GHC ghc-devs at haskell.org
Fri Jan 12 16:24:29 UTC 2018


#14331: Overzealous free-floating kind check causes deriving clause to be rejected
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.4.1
       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):

 Sorry goldfire, I didn't realize you were referring to
 comment:14:ticket:11732 in particular when you referenced #11732 (which
 has a much different program than the original one I copy-pasted in
 comment:55). Yes, I was originally of the belief that `deriving` should be
 allowed to unify whatever it likes, which is why I originally argued so
 vehemently against the ideas put forth in this ticket. I've since changed
 my opinion on the matter after reading the discussion here, and believe
 that the program in comment:14:ticket:11732 should fail.

 FWIW, programs like in comment:14:ticket:11732 are quite rare in practice,
 so I wouldn't anticipate too much breakage from disallowing them. The only
 comparable example that I can think of which is widely used in practice is
 when you derive `Generic1`, since the kind of `Generic1` is `(k -> Type)
 -> Constraint`, and one frequently unifies that `k` with `Type`.
 Fortunately, almost everyone writes their derived `Generic1` instances as

 {{{#!hs
 data Foo (a :: Type) = ... deriving Generic1
 }}}

 where the `k` argument to `Generic1` isn't specified, so it's allowed to
 freely unify with `Type`. It'd be a problem if folks were writing the
 above as

 {{{#!hs
 data Foo (a :: Type) = ... deriving ((Generic1 :: (k -> Type) ->
 Constraint))
 }}}

 But thankfully, only crazy people like myself have ever attempted this. :)

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


More information about the ghc-tickets mailing list