
#8851: Standalone deriving and GND behave differently --------------------------------------------+------------------------------ Reporter: simonpj | Owner: goldfire Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type checker) | Version: 7.8.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by goldfire): I agree fully with Simon's analysis. But, the solution to this problem gets involved with areas of GHC that I'm not terribly familiar with, and I need some guidance before proceeding. The interesting bit is `simplifyDeriv` in !TcDeriv, which has this chunk: {{{ ; wanted <- mapM (\(PredOrigin t o) -> newFlatWanted o (substTy skol_subst t)) theta ; (residual_wanted, _ev_binds1) <- solveWantedsTcM (mkFlatWC wanted) }}} I can understand quite clearly what this is doing. It's creating a new `wanted` constraint for each (skolemised) predicate in `theta`. Then, we throw the set of wanteds into the constraint solver and see what comes out. Processing that happens below here figures out if `residual_wanted` indicates success or failure. The problem is that we now wish to do all of the above with some assumptions. My first thought was to create an implication constraint for this, but it's not clear to me the right way to set it up. I found `checkConstraints`, which seems quite relevant, but I'm not sure what to pass for its `thing_inside`. Change the `newFlatWanted` to something that ''emits'' the wanteds? Then, what do I pass to `solveWantedsTcM`? Do I really want `solveWantedsTcMWithEvBinds`? But, that functions takes an `EvBindsVar`, and `checkConstraints` gives me a `TcEvBinds`, which may or may not contain the `EvBindsVar`. (I believe that, in this case, it ''will'' always contain the `EvBindsVar`, but this seems like a silly thing to rely on.) In any case, I'm not sure which lever will drive the ship to safety and which knob will sink the whole lot. Any advice is appreciated, or if you're short of time, you're welcome to yank this bug from me and fix it yourself. In any case, I will need to learn about these interactions quite soon in other work, so the timing is perfect. Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8851#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler