#3877: Require XOverlappingInstances for the most specific instance only
----------------------------------------+-----------------------------------
  Reporter:  traz161616                 |          Owner:                       
      Type:  feature request            |         Status:  new                  
  Priority:  normal                     |      Milestone:  7.2.1                
 Component:  Compiler (Type checker)    |        Version:  6.12.1               
Resolution:                             |       Keywords:  XOverlappingInstances
  Testcase:                             |      Blockedby:                       
Difficulty:                             |             Os:  Unknown/Multiple     
  Blocking:                             |   Architecture:  Unknown/Multiple     
   Failure:  GHC rejects valid program  |  
----------------------------------------+-----------------------------------

Comment(by simonpj):

 OK so the current rule is this:
  * If an instance decl is compiled with `-XOverlappingInstances` then it
 can be overlapped by a more-specific instance.  The (later) more specific
 instance does not need to be compiled with `-XOverlappingInstances`

 You want precisely the reverse of this. The less-specific instance is in
 some library compiled without `-XOverlappingInstances`, and you want to
 write an instance that deliberately overlaps it.

 To make this change would break other people's code, because a library
 author could not write an instance declaration (such as a "default
 instance" `instance Foo a where...`) that he ''expects'' to be overlapped.

 So to meet your goals, we either need a new flag altogether (which seems a
 bit heavyweight), or to say
  * Overlap between two instance decls is allowed if ''either'' (or both)
 of them was compiled with `-XOverlappingInstances`.

 This seems reasonable to me... one party or the other has to agree to an
 overlap.  It's a bit more liberal than the current policy.

 Ok with everyone?  It's a one-line change to the code; a bit more in the
 documentation.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3877#comment:11>
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