[GHC] #9821: DeriveAnyClass support for higher-kinded classes + some more comments

GHC ghc-devs at haskell.org
Fri Feb 3 16:34:51 UTC 2017


#9821: DeriveAnyClass support for higher-kinded classes + some more comments
-------------------------------------+-------------------------------------
        Reporter:  dreixel           |                Owner:  dreixel
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  7.9
      Resolution:                    |             Keywords:  Generics
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #5462, #9968,     |  Differential Rev(s):  Phab:D2961
  #12144                             |
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 >  but it talks about inferring most general types, which I'm not sure is
 relevant to this story or not

 Yes it's relevant.  In inferring "???" we are indeed trying to infer the
 most general type for the instances.  We seek the context with fewest
 constraints (i.e. most general).

 The equalities thing doesn't matter much, but for consistency with
 `simplifyInfer` set it to `True`.

 >  What are CX and RC here?

 I defined them earlier in the text you quoted!  RC = residual context, CX
 is what we decide ??? should be.

 > Also, should I interpret this as meaning that if there are any
 implication constraints leftover after solving which contain something of
 the form forall x. C => Foo x (i.e., if there are constraints which
 contain type variables other than the class's type variables), that should
 be an error?

 Yes, certainly.  Notice that `approximateWC` doesn't remove the
 constraints it floats out; it just floats them out. They are still there
 in RC; but we'll solve them easily from CX.

 >  Do we already take care of this with ​these lines in TcDerivInfer:

 I'm not sure.. too much is in flux.  But you don't need to solve it
 because you don't need to know the answer here: just emit it and it'll get
 solved later.

 > Are you saying that I should literally use simplifyInfer to solve these
 implications

 No: sharing code with `simplifyInfer` in due course would be a good plan,
 but it does a lot more so just use it as a source of inspiration, no more.

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


More information about the ghc-tickets mailing list