[GHC] #10009: type inference regression when faking injective type families

GHC ghc-devs at haskell.org
Wed Apr 29 14:05:07 UTC 2015


#10009: type inference regression when faking injective type families
-------------------------------------+-------------------------------------
        Reporter:  aavogt            |                   Owner:
            Type:  bug               |                  Status:  new
        Priority:  high              |               Milestone:  7.10.2
       Component:  Compiler (Type    |                 Version:  7.10.1-rc1
  checker)                           |                Keywords:
      Resolution:                    |            Architecture:
Operating System:  Unknown/Multiple  |  Unknown/Multiple
 Type of failure:  GHC rejects       |               Test Case:
  valid program                      |                Blocking:
      Blocked By:                    |  Differential Revisions:
 Related Tickets:  #10226            |
-------------------------------------+-------------------------------------

Comment (by Simon Peyton Jones <simonpj@…>):

 In [changeset:"a1275a762ec04c1159ae37199b1c8f998a5c5499/ghc"]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="a1275a762ec04c1159ae37199b1c8f998a5c5499"
 Improve improvement in the constraint solver

 This regrettably-big patch substantially improves the way in which
 "improvement" happens in the constraint solver.  It was triggered by
 trying to crack Trac #10009, but it turned out to solve #10340 as
 well.

 The big picture, with several of the trickiest examples, is described
 in Note [The improvement story] in TcInteract.

 The major change is this:

 * After solving we explicitly try "improvement", by
      - making the unsolved Wanteds into Deriveds
      - allowing Deriveds to rewrite Deriveds
   This more aggressive rewriting "unlocks" some extra
   guess-free unifications.

 * The main loop is in TcInteract.solveSimpleWanteds, but I also ended
   up refactoring TcSimplify.simpl_loop, and its surrounding code.

   Notably, any insolubles from the Givens are pulled out
   and treated separately, rather than staying in the inert set
   during the solveSimpleWanteds loop.

 There are a lot of follow-on changes

 * Do not emit generate Derived improvements from Wanteds.
   This saves work in the common case where they aren't needed.

 * For improvement we should really do type-class reduction on Derived
   constraints in doTopReactDict.  That entailed changing the GenInst
   constructor a bit; a local and minor change

 * Some annoying faffing about with dropping derived constraints;
   see dropDerivedWC, dropDerivedSimples, dropDerivedInsols,
   and their Notes.

 * Some substantial refactoring in TcErrors.reportWanteds.
   This work wasn't strictly forced, but I got sucked into it.
   All the changes are in TcErrors.

 * Use TcS.unifyTyVar consistently, rather than setWantedTyBind,
   so that unifications are properly tracked.

 * Refactoring around solveWantedsTcM, solveWantedsAndDrop.
   They previously guaranteed a zonked result, but it's more
   straightforward for clients to zonk.
 }}}

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


More information about the ghc-tickets mailing list