[GHC] #13814: Unable to resolve instance for polykinded superclass constraint on associated-type-family.

GHC ghc-devs at haskell.org
Sun Jun 11 15:29:32 UTC 2017


#13814: Unable to resolve instance for polykinded superclass constraint on
associated-type-family.
-------------------------------------+-------------------------------------
        Reporter:  isovector         |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:  polykinds,
                                     |  type families
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 Very strange indeed. If you comment out the `Front Int` instance and
 inspect the file using GHCi and `-fprint-explicit-kinds`, you'll uncover
 something odd:

 {{{
 GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
 Loaded GHCi configuration from /home/rgscott/.ghci
 [1 of 1] Compiling Test             ( Bug.hs, interpreted )
 Ok, modules loaded: Test.
 λ> :i Back
 class Back k (t :: k)   -- Defined at Bug.hs:7:1
 instance [safe] Back * Bool -- Defined at Bug.hs:12:10
 λ> :i Front
 class Back (GHC.Prim.Any *) (FrontBack (GHC.Prim.Any *) k t) =>
       Front k (t :: k) where
   type family FrontBack k1 k (t :: k) :: k1
         -- Defined at Bug.hs:9:1
 }}}

 The definition the `Back` class looks fine. But the definition of `Front`
 is quite bizarre! I'm not sure how `Any` is being introduced here, since I
 would have expected it to be this:

 {{{#!hs
 class Back k1 (FrontBack k1 k t) =>
       Front k (t :: k) where
   type family FrontBack k1 k (t :: k) :: k1
 }}}

 I suppose this also explains the confusing error message. If you try
 compiling the `Front Int` error message with `-fprint-explicit-kinds`,
 you'll see that:

 {{{
     • No instance for (Back
                          (GHC.Prim.Any *) (FrontBack (GHC.Prim.Any *) *
 Int))
         arising from the superclasses of an instance declaration
     • In the instance declaration for ‘Front * Int’
 }}}

 No wonder it's failing - we have an instance for `Back * (FrontBack * *
 Int)`, not for `Back (Any *) (FrontBack (Any *) * Int)`.

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


More information about the ghc-tickets mailing list