OK, I understand this.

1.  You really do have overlapping instances, exactly as reported in the error 
message.  

2.  The instance in Data.Graph.Inductive.Graph looks like this
        instance ... => Eq (gr a b)
     This is, as you say, crazy, because it overlaps with every arity-2 type 
constructor.
     In particular, it overlaps with Eq (a,b)

     I'm copying Martin Erwig, who is, I think the maintainer of the fgl/ 
package, because
     it seems to me that it should be fixed.

3.  Strictly speaking, GHC should only "see" instances that are in the 
transitive closure
     of the imports of the module being compiled.  In fact, though, in --make 
mode, GHC
     has an ever-increasing heap of instances, accumulated from all the 
non-home-package
     modules it has seen so far, a superset of the ones that are "below" the 
one being 
    compiled.

     In your example, the bad Data.Graph.Inductive.Graph is not below Anno, so 
arguably
     it should not have an overlapping instance reported; but in fact a 
from-scratch --make
     sees the bad instance from the time it compiles MyTree onwards.


My response.  At the cost of more work, GHC could check exactly the right 
instances.  But I'm not sure it's worth the bother (and it'd make GHC less 
efficient).  The real problem is the overlapping instances.

Simon

| -----Original Message-----
| From: Christian Maeder [mailto:[EMAIL PROTECTED]
| Sent: 07 December 2004 11:39
| To: Simon Peyton-Jones
| Cc: Till Mossakowski; Klaus Lüttich; [EMAIL PROTECTED]
| Subject: visibility of instances (was: Bug in compiling large projects ?)
| 
| Simon Peyton-Jones wrote:
| > I remember this one from before.
| >
| > We're not planning to do significant more work on the 6.2 branch, so I'm 
not inclined to hunt this
| one down unless it happens on the HEAD too.
| >
| > Can you find out whether it does?
| 
| I think it does. I've found a small example, that does not depend on
| uni, but is different in that it only occurs if it is compiled without
| -fallow-overlapping-instances. If everything is compiled in one go, the
| compilation fails, but goes through if the command is simply repeated.
| 
| I assume that an insane instance creeps in from
| Data.Graph.Inductive.Tree. This module is part of the new ghc library
| and currently (for ghc 6.2.2) we are using a separate copy of it.
| Anno.hs is completely independent from trees and only rejected
| because/when MyTree.hs is compiled before within the same call.
| 
| HTH Christian
| 
| [EMAIL PROTECTED] -> ghc --version
| The Glorious Glasgow Haskell Compilation System, version 6.3.20041201
| [EMAIL PROTECTED] -> ghc --make compile.hs
| Chasing modules from: compile.hs
| Compiling MyTree           ( ./MyTree.hs, ./MyTree.o )
| Compiling Anno             ( ./Anno.hs, ./Anno.o )
| 
| ./Anno.hs:7:21:
|      Overlapping instances for Eq (Int, Int)
|        arising from use of `==' at ./Anno.hs:7:21-22
|      Matching instances:
|        Imported from `Data.Graph.Inductive.Graph':
|          instance (Eq a, Eq b, Data.Graph.Inductive.Graph.Graph gr) =>
| Eq (gr a b)
|        Imported from `Data.Tuple': instance (Eq a, Eq b) => Eq (a, b)
|      In the definition of `==':
|          == Unparsed_anno aw1 at1 _ Unparsed_anno aw2 at2 _ = (aw1, at1)
| == (aw2, at2)
|      In the definition for method `=='
|      In the instance declaration for `Eq Annotation'
| [EMAIL PROTECTED] -> ghc --make compile.hs
| Chasing modules from: compile.hs
| Skipping  MyTree           ( ./MyTree.hs, ./MyTree.o )
| Compiling Anno             ( ./Anno.hs, ./Anno.o )
| Compiling Main             ( compile.hs, compile.o )
| Linking ...
| [EMAIL PROTECTED] -> ./a.out
| Hello World
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to