Unexpected constraint when using ExistentialQuantification
Hello! Consider this simple code:
data Elem t = Typeable t => Elem Int tst1 :: forall a. Elem a -> TypeRep tst1 (Elem _) = typeRep (Proxy :: Proxy a)
It works and it should work.
Elem is created only to be sure that if we've got a value of type
Elem t we don't have to check that
Typeable. <offtopic> By the way, exystential newtypes would be so awesome in GHC! </offtopic>
And now a strange thing. If we create another function:
tst2 :: forall a. Elem a -> TypeRep tst2 _ = typeRep (Proxy :: Proxy a)
GHC throws error that there is no
Typeable a constraint. The only difference between
tst2 is different pattern binding.
|Component||Compiler (Type checker)|