Skip to content

Defaulting of RuntimeRep in type families is incorrect

Consider

{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies #-}
import Data.Kind
import GHC.Types

data A (r :: RuntimeRep)

type family IsA r where
  IsA (A _) = Char
  IsA _     = Int

f :: IsA (A UnliftedRep)
f = 'a'

This program is rejected by ghc-8.8 and master. The reason is that the type family is changed to:

type family IsA r where
  IsA (A 'LiftedRep) = Char
  IsA _              = Int

The behavior was correct in ghc 8.6.

Credits to @facundominguez for finding the intial version of this bug.

The bug does not happen if the underscore is replaced with a variable IsA (A x) = Char.

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