Skip to content

Empty unlifted sums are always uninhabited

Summary

Every type of kind TYPE ('SumRep '[]) is uninhabited. GHC's exhaustivity checker doesn't recognize this.

Steps to reproduce

{-# LANGUAGE UnliftedNewtypes, TypeInType, MagicHash, EmptyCase, GADTs, ScopedTypeVariables #-}

newtype Uninhab# :: TYPE ('SumRep '[]) where
  Uninhab# :: Uninhab# -> Uninhab#

absurd# :: forall r (a :: TYPE r). Uninhab# -> a
absurd# v = case v of

This produces a pattern coverage warning.

Expected behavior

I expect GHC to recognize that every type of kind TYPE ('SumRep '[]) is uninhabited. It should therefore accept the empty case as complete.

Environment

  • GHC version used: 8.10.1

Optional:

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