Skip to content

Any is chosen as representant of data kind without constructor

Summary

When lifting data types without any constructors ghc sometimes chooses GHC.Types.Any as representant of that kind. This causes absurd like functions to be called with an actual value.

Steps to reproduce

{-# LANGUAGE
    DataKinds,
    KindSignatures,
    EmptyCase
#-}
module Test(test) where
import Data.Proxy
import Data.Void

absurdProxy :: Proxy (v :: Void) -> a
absurdProxy p = case p of {}
{-# NOINLINE absurdProxy #-}

test = absurdProxy Proxy

When compiling with -ddump-simpl you get this output for test:

test :: forall {a}. a
[GblId, Str=b, Cpr=b]
test
  = \ (@a_akm) ->
      absurdProxy_rjQ
        @GHC.Types.Any @a_akm (Data.Proxy.Proxy @Void @GHC.Types.Any)

Expected behavior

  • The empty case in absurdProxy should b considered total
  • absurdProxy should not me callable

Environment

  • GHC version used: 9.0.1
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information