Hello, I am confused by the type error when I am trying to compile this code:
import Type.Equality (class TypeEquals)
foo :: forall a. TypeEquals String a => a
foo = "hi"
“Could not match type String with type a0”
TypeEquals a b
is a type class with a -> b, b -> a
dependencies, which I thought the type checker should be able to realise a
must be String.
Haskell gives the same error, but it has TypeFamilies so I can express this:
foo :: forall a. String ~ a => a
Is it a bug or is it intended?
Thank you very much!