Marcin 'Qrczak' Kowalczyk wrote:
[snip]
> I am worried if the following scenario is possible: There are
> two modules. Everything is OK. Now one of them adds an innocent
> instance. It is perfectly correct in its context, but it happens that
> it triggers an ambiguity in the second module. Still neither module
> itself is at fault.
[snip]
> I don't have a concrete case in mind...
[snip]

I do though.  I mentioned it before.  I don't see how you can get a worse example in
principle than this.

Module 1:
   class Integral number where
      [ operations on numbers ]
   instance Integral number => Show number where
      [ extract digits in obvious way ]
 
Module 2:
    class String string where
       [ operations on strings ]
    class String string => Show string where
       [ extract canonical ASCII string representation ]

As a matter of fact GHC would not have a problem with these modules 
(unless perhaps someone imports both of them - I don't know if it checks that).
In any case I would rather it didn't have a problem with them.  I suspect some of
my code already relies on it not having a problem.

Now suppose J. Random User comes along three years later and adds something that's
an instance of both Integral and String.  S/he tries to show this hybrid.  
Then we DO have a problem.  But not until then.  I personally think it's quite
alright to print out a message at this stage along the lines of "I'm sorry, I can't 
work out which instance of Show to use, because it could come from Integral (see 
Module 1)
or from String (see Module 2)."

Compare the case when Modules 1 & 2 give the same symbol different definitions.  
Haskell
doesn't have a problem.  It doesn't even have a problem if you import the two modules 
in
the same file.  It only has a problem if you try and use that symbol in that file.

_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to