Skip to content

Erroneous repeated kind variable in conflicting type family instance error message

Consider the following code:

{-# LANGUAGE TypeFamilies, PolyKinds #-}

type family F (a :: k1) (b :: k2)
type instance F a a = Int
type instance F a b = Bool

GHC correctly complains that these instances overlap. The error message is this:

/Users/rae/temp/Scratch.hs:4:15:
    Conflicting family instance declarations:
      F k k a a -- Defined at /Users/rae/temp/Scratch.hs:4:15
      F k k a b -- Defined at /Users/rae/temp/Scratch.hs:5:15

The problem is the repeated k kind variable in the second line, above. The type variables a and b can have different kinds, so the kind variables should be, say, k1 and k2. (The repeated k variable in the first line is correct.)

While I realize I have been playing around most recently in the type family code, I think this problem is further up the chain than where I've been writing.... it would seem to be that whatever code generates kind variables is generating multiple ones with the same name (but hopefully different Uniques!). This behavior is the same in 7.6.1 as it is in HEAD (7.7.20121221).

Trac metadata
Trac field Value
Version 7.7
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information