[GHC] #8994: type checker could not deduce ambiguous instances

GHC ghc-devs at haskell.org
Mon Apr 14 09:31:34 UTC 2014


#8994: type checker could not deduce ambiguous instances
-------------------------------------+------------------------------------
        Reporter:  divip             |            Owner:
            Type:  bug               |           Status:  closed
        Priority:  normal            |        Milestone:
       Component:  Compiler          |          Version:  7.8.2
      Resolution:  invalid           |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  None/Unknown      |       Difficulty:  Unknown
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------
Changes (by simonpj):

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


Comment:

 The reason this works in 7.6.3 is because GHC defaults the ambiguous type
 variable 'b', which arises from the call to `f` in `run (f 0)`.  It sets
 `b := Integer`, and all is well.

 But 7.8 is more cautious about defaulting.  Consider:
 {{{
 class (c ~ Int) => C a c where
   type F a
   f :: b -> a

 run :: (forall a c. C a c => a) -> ()
 }}}
 In this form there is another way to make the program typecheck, by
 setting `b := c`.

 So GHC's defaulting rule (which is necessarily ad-hoc, and always was), is
 a bit more conservative in 7.8, and declines to set `b := Integer` in case
 you really intended `b := c`.  So you need a type signature.

 This would not be a hard design choice to liberalise. But I erred on the
 side of being conservative.

 Generally speaking it's better not to rely on defaulting, anyway. Just use
 that type signature!

 I'll close as invalid, but I'm open to user pressure!


 Simon

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


More information about the ghc-tickets mailing list