[GHC] #7578: Instance selection regression from 7.4 to 7.6

GHC cvs-ghc at haskell.org
Mon Jan 14 18:46:03 CET 2013


#7578: Instance selection regression from 7.4 to 7.6
--------------------------------------+-------------------------------------
  Reporter:  nomeata                  |          Owner:                  
      Type:  bug                      |         Status:  closed          
  Priority:  normal                   |      Milestone:                  
 Component:  Compiler (Type checker)  |        Version:  7.6.1           
Resolution:  invalid                  |       Keywords:                  
        Os:  Unknown/Multiple         |   Architecture:  Unknown/Multiple
   Failure:  None/Unknown             |     Difficulty:  Unknown         
  Testcase:                           |      Blockedby:                  
  Blocking:                           |        Related:                  
--------------------------------------+-------------------------------------
Changes (by simonpj):

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


Comment:

 Currently this is by-design.  What is happening is this.  At the local
 binding of `()`, GHC is trying to infer the most general type of the
 binding.  It sees a constraint `(CollectArgs b)` but at that moment it has
 a very local view, so it tries to simplify it. Aha. There is an instance
 declaration `instance Show a => CollectArgs a` which matches.  Let's use
 that!  Disaster.

 You are skating on very thin ice indeed, becuase there are two ways of
 seeming to satisify `(CollectArgs b)`, one from the context of the first
 instance decl, and one from the second instance decl itself.

 The simple way to fix this is to use `-XMonoLocalBinds` which stops GHC
 trying to generalise the type of the local declatation. This is good in
 lots of ways: see [http://research.microsoft.com/en-
 us/um/people/simonpj/papers/constraints/index.htm Let should not be
 generalised].  I'd be happy for it to be the default, and it's implied by
 `-XGADTs` and similar, but currently the default is still to generalise
 local bindings.

 Simon

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7578#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the ghc-tickets mailing list