Skip to content

Last type family equation ignored (regression in 9.4)

Summary

In the example below every equation after the first one is ignored since GHC 9.4. It is handled correctly in GHC 9.2.

Steps to reproduce

{-# LANGUAGE TypeFamilies #-}

import Data.Kind

type Foo :: forall k . k -> k
type family Foo a where
  Foo @Type a = a
  Foo @Constraint a = a
ghci> :kind! Foo Int
Foo Int :: *
= Int -- Good!

ghci> :kind! Foo (Show Int)
Foo (Show Int) :: Constraint
= Show Int -- Good! (GHC 9.2.5)
= Foo (Show Int) -- Bad :( (GHC 9.4.8)

In the above example, it seems to me that Foo (Show Int) should match the second equation of Foo. But instead, the type family gets stuck, as though the second equation wasn't there at all.

Swapping the equations would produce the opposite behavior, Show Int would reduce but Int would not.

Expected behavior

Don't get stuck, evaluate to Show Int.

Environment

  • GHC version used: 9.10.1, GHC 9.4.8, GHC 9.2.5

Optional:

  • Operating System: Windows 11
  • System Architecture: x86_64
Edited by Jakob Brünker
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information