Skip to content

Change GHC.Exts.Any to a type family

I just had this slightly alarming interchange with GHCi:

Prelude> import Data.Type.Equality
Prelude Data.Type.Equality> import GHC.Exts
Prelude Data.Type.Equality GHC.Exts> :kind! ((Any :: Bool) == (Any :: Bool))
((Any :: Bool) == (Any :: Bool)) :: Bool
= 'False

After staring at the result in disbelief, I figured out why. The instance for == at kind Bool looks like this:

type family EqBool a b where
  EqBool False False = True
  EqBool True  True  = True
  EqBool a     b     = False
type instance (a :: Bool) == (b :: Bool) = EqBool a b

Well, Any isn't False, Any isn't True, so Any == Any must be False!

The solution to this, of course, is to make Any a type family, not a datatype. Then, it wouldn't be apart from the equations in EqBool. I believe this idea has been floated previously but was not implemented as it would have disturbed !TypeLits and/or singletons. These libraries have been updated, and it's time.

I'm happy to do this myself in due course.

Trac metadata
Trac field Value
Version 7.8.2
Type Task
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information