Skip to content

Kind inference bug in type family declaration

Consider this (cut down from #17113 (closed))

{-# LANGUAGE MagicHash, UnboxedTuples, TypeInType, TypeFamilies, TypeOperators #-}

module Test where

import GHC.Exts

type family TypeReps xs where
   TypeReps '[]                 = '[]
   TypeReps ((a::TYPE k) ': as) = k ': TypeReps as

type family Tuple# xs = (t :: TYPE ('TupleRep (TypeReps xs))) where
   Tuple# '[a]                 = (# a #)

This compiles fine with GHC 8.6.4, but fails thus with HEAD:

T17113.hs:14:34: error:
    • Expected kind ‘TYPE ('TupleRep (TypeReps xs))’,
        but ‘(# a #)’ has kind ‘TYPE ('TupleRep '[ 'LiftedRep])’
    • In the type ‘(# a #)’
      In the type family declaration for ‘Tuple#’
   |
14 |    Tuple# '[a]                 = (# a #)
   |                                  ^^^^^^^

Notice that free xs in the error message which is completely bogus. Something is badly wrong.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information