Note [The squishiness of the ambiguity check]
What about this? g :: C [a] => Int Is every call to 'g' ambiguous? After all, we might have instance C [a] where ... at the call site. So maybe that type is ok! Indeed even f's quintessentially ambiguous type might, just possibly be callable: with -XFlexibleInstances we could have instance C a where ... and now a call could be legal after all! Well, we'll reject this unless the instance is available *here*. But even that's not quite right. Even a function with an utterly-ambiguous type like f :: Eq a => Int -> Int is still callable if you are prepared to use visible type application, thus (f @Bool x). In short, the ambiguity check is a good-faith attempt to say "you are likely to have trouble if your function has this type"; it is NOT the case that "you can't call this function without giving a type error". See also Note [Ambiguity check and deep subsumption] in GHC.Tc.Utils.Unify.
References 1
- Ambiguity check and deep subsumption GHC.Tc.Utils.Unify
Referenced by 1
- Ambiguity check and deep subsumption GHC.Tc.Utils.Unify