TypeRep equality false negative for function types
Summary
There are, it would seem, multiple unequal TypeRep
representations of the same function type.
Steps to reproduce
{-# LANGUAGE GHC2024 #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
import Data.Kind (Constraint)
import Data.Proxy
import Data.Typeable
type Reassemble :: k -> k -> Constraint
class Reassemble a b | a -> b
instance {-# OVERLAPPABLE #-} a ~ a' => Reassemble a a'
instance (Reassemble f f', Reassemble a a', fa ~ f' a') => Reassemble (f a) fa
test :: forall a b. (Typeable a, Typeable b, Reassemble a b) => Proxy a -> String
test pa | typeRep pa == typeRep pb = "Equal!\n"
| otherwise =
"Not equal:\n" <>
show (typeRep pa) <> "\n" <>
show (typeRep pb) <> "\n"
where pb = Proxy @b
main :: IO ()
main = do
putStrLn $ test (Proxy @([(Bool, [Int])]))
-- Equal!
putStrLn $ test (Proxy @(Bool -> Int))
-- Not equal:
-- Bool -> Int
-- FUN 'Many ('BoxedRep 'Lifted) ('BoxedRep 'Lifted) Bool Int
Expected behavior
Both should be equal. (Oddly enough, they are if the Reassemble a b
constraint is moved to the front of the test
context!)
Environment
- GHC version used: 9.12.2