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

GHC ghc-devs at haskell.org
Mon Feb 6 23:41:47 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):

 Further clarifications

 > Currently in simplifyDeriv, we are using the function simplifyWantedsTcM
 to simplify the constraints, which seemed to work well back when all of
 our deriving-related constraints were simple wanteds. But now we're
 throwing implication constraints into the mix. Are you proposing to
 replace the use of simplifyWantedsTcM entirely with something   la
 simplifyInfer? Are you proposing to invoke a simplifyInfer-like function
 after simplifyWantedsTcM? Something else?

 Something like `simplifyInfer`, but simpler.   Call `simplifyWanteds`;
 then `approximateWC`; then `mkMinimalBySCs`; then emit the residual
 constraint as above.

 > 2.    When you say "just emit this implication": `forall d. CX => RC`..
 To tie it back to your example in comment:10, are you proposing to emit
 this?
 {{{
 forall d. Show d => ((forall b. () => (Show d, C d b)) ^ (forall . Eq
 (Maybe d) => (Ord d, Show d))
 }}}
 > That is, letting
 {{{
 CX = (Show d)
 RC = ((forall b. () => (Show d, C d b)) ^ (forall . Eq (Maybe d) => (Ord
 d, Show d))
 }}}

 Maybe you meant comment:14. Then yes.  (There are several related examples
 in comment:14, so I'm not sure precisely which one you mean.

 > I see that there is a function emitImplication, which appears to modify
 the state of TcM. But I'm still unsure of when the error message involving
 (C d b) is supposed to be thrown. That is, what specific action causes the
 typechecker to see the bogus (C d b) and complain?

 It's the `simplifyTop` called right at the top level, in `TcRnDriver`.
 Most constraint solving is done by this single call to `simplifyTop`; only
 when we MUST solve eagerly (as here, to get CX) do we call the solver.
 Usually we just toss the unsolved constraint into the monad and solve it
 right at the end.

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


More information about the ghc-tickets mailing list