[GHC] #14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code

GHC ghc-devs at haskell.org
Wed Dec 13 17:28:27 UTC 2017


#14579: GeneralizedNewtypeDeriving produces ambiguously-kinded code
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.2
  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):  Phab:D4264
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 What change to `typeToHsType` do we want? The problem is to specify the
 invisible kind arguments to occurrences of poly-kinded type-constructor
 applications.  Eg
 {{{
 instance Eq a => Eq (Glurp a) where
     (==)
       = coerce
           @(Wat 'Proxy -> Wat 'Proxy -> Bool)
           @(Glurp a -> Glurp a -> Bool)
           (==)
 }}}
 The problem is the invisible kind arguments to the poly-kinded `'Proxy`
 occurrences.  If we had visible kind application we could use that, but we
 don't.  Solution: add a kind signature, as in the Description:
 {{{
 instance Eq a => Eq (Glurp a) where
   (==) = coerce @(Wat ('Proxy :: Proxy a) -> Wat ('Proxy :: Proxy a) ->
 Bool)
                 @(Glurp a                 -> Glurp a                 ->
 Bool)
                 (==)
 }}}
 When do we need a kind signature?

 * (a) When we have an application of a type constructor with invisible
 arguments
 * (b) And the invisible arguments are not fixed by the kinds of the
 visible arguments.

 Probably just using (a) is enough to reduce the noise of redundant kind
 signatures
 to reasonable levels.

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


More information about the ghc-tickets mailing list