
On 20 May 2010 16:50, Carlos Camarao
Using the available instances to resolve overloading is a tricky thing, it's very easy to make things break that way.
Using the available instances is the natural, in fact the only way, to resolve overloading.
AFAIK no other Haskell feature is defined in terms of "available instance" information. Overloaded functions are resolved by at least these mechanisms: * Defaulting * Information from unification (including from user-defined type signatures) * Functional dependencies propagating information "Available instances" are not a natural addition to this list. In particular, using that information can cause programs to become untypeable when the module or *any module it imports transitively* defines a new instance. This leads to programs that are extremely fragile in the face of changes in the libraries! (Admittedly you can get the same issue with GHC Haskell as it is right now if you define an orphan instance in your module) The situation is even worse if you consider "available" instances to also include orphans defined in non-imported modules (as a whole-program compiler way very well do), because then you don't even need to have transitively imported the module which has added an instance for your program to stop type-checking. Furthermore, if you intend to use an "overloaded" function at *one particular instance*, you could just have written the monomorphic type to begin with and not even bothered with overload resolution.
Our proposal cannot make any well-typed program break, any program whatsoever.
That is true, but it makes extra things type check in a really fragile way. I'm not keen. Cheers, Max