#1549: ghc derives different type signature for equal functions with overlapping
instances
----------------------------------------+-----------------------------------
    Reporter:  int-e                    |        Owner:         
        Type:  bug                      |       Status:  closed 
    Priority:  normal                   |    Milestone:         
   Component:  Compiler (Type checker)  |      Version:  6.7    
    Severity:  normal                   |   Resolution:  invalid
    Keywords:                           |   Difficulty:  Unknown
          Os:  Linux                    |     Testcase:         
Architecture:  x86                      |  
----------------------------------------+-----------------------------------
Changes (by simonpj):

  * resolution:  => invalid
  * status:  new => closed

Comment:

 The rules for instance overlap are described here:
 http://www.haskell.org/ghc/docs/latest/html/users_guide/type-
 extensions.html#instance-overlap

 When compiling B.hs, GHC sees that there is an overlapping instance and so
 refrains from simplifying the constraint `Monad (A.MaybeT m)`, becuase `m`
 might be instantiated to `Foo`.  But when compiling C.hs, it sees no such
 overlap, so it simplifies the constraint.  It doesn't see the overlap
 because B is not in the transitive imports of C.

 That's why you get different types.  To get the same types, we'd have to
 refrain from '''ever''' using an instance declaration in case it was later
 overlapped, and that seems impractical becuase it would percolate all
 constraints up to `main`.

 In short, this seems to be the documented behaviour.  But the
 documentation may not be adequately clear. If you can suggest concrete
 improvements (E.g. Add ".." after "...") then that would be v helpful.
 Thanks.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1549>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to