
#15376: GHC determine illegal kind for standalone deriving with Deriving via -------------------------------------+------------------------------------- Reporter: mizunashi_mana | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: Resolution: | Keywords: deriving Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: 14331 | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: kosmikus (added) * blockedby: => 14331 Comment: This is indeed a known limitation of the way `deriving` declarations are typechecked. //Short answer//: You can work around the issue by introducing an explicit type signature, i.e., {{{#!hs deriving via (f :: * -> *) instance Functor f => Functor (FunctorWrapped f) }}} //Long answer//: Any type variables quantified by `via` are kind-checked in isolation, without any information that might be gleaned from bidirectionally kind-checking the instance head. This means that GHC sees: {{{ deriving via f ... }}} And hastily concludes that `f` is of kind `*`. Bummer. We (kosmikus, Iceland_jack, and I) discussed this at some length in https://github.com/RyanGlScott/ghc/issues/29, and came to the conclusion that we might be able to fix this issue by introducing fresh unification variables when kind-checking, then unifying, and then generalizing/skolemizing if there are any unfilled unification variables left. This bears a close resemblance to the algorithm described in https://ghc.haskell.org/trac/ghc/ticket/14331#comment:31, so I'm going to claim that this ticket is blocked by #14331. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15376#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler