[GHC] #12814: Should GND infer an instance context when deriving method-free classes?

GHC ghc-devs at haskell.org
Tue Nov 8 19:05:05 UTC 2016


#12814: Should GND infer an instance context when deriving method-free classes?
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #11369, #12810    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by goldfire):

 I'm happy with Ryan's patch, too. But I'm still think my new approach
 would be simpler than the existing one.

 (a) is already done. That's !TcGenDeriv.

 (b) is already done: `tcInstDcls` (or similar)

 (c) will be the set of unsolved wanted constraints left over after
 solving. These will have to be checked for exoticness, but that's it!

 (d) is simply taking the result of (c) and sticking it in the instance
 decl. There is a matter that (c) outputs `Type` and (d) will want
 `HsContext` -- but I think we already have a way of squirreling a `Type`
 inside of an `HsType`, so this shouldn't be bad.

 (e) would be necessary, and it would be repeated work. So this new
 approach is probably slower than the existing one.

 In exchange, we get to delete the first several hundred lines of
 !TcDerivInfer (`inferConstraints`).

 In any case, if it's not broken, perhaps we shouldn't fix it. I just find
 that special-casing the 0-method case to be a bit odd.

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


More information about the ghc-tickets mailing list