Skip to content
  • Simon Peyton Jones's avatar
    Kill floatEqualities completely · 995a8f9d
    Simon Peyton Jones authored and Marge Bot's avatar Marge Bot committed
    This patch delivers on #17656, by entirel killing off the complex
    floatEqualities mechanism.  Previously, floatEqualities would float an
    equality out of an implication, so that it could be solved at an outer
    level. But now we simply do unification in-place, without floating the
    constraint, relying on level numbers to determine untouchability.
    
    There are a number of important new Notes:
    
    * GHC.Tc.Utils.Unify Note [Unification preconditions]
      describes the preconditions for unification, including both
      skolem-escape and touchability.
    
    * GHC.Tc.Solver.Interact Note [Solve by unification]
      describes what we do when we do unify
    
    * GHC.Tc.Solver.Monad Note [The Unification Level Flag]
      describes how we control solver iteration under this new scheme
    
    * GHC.Tc.Solver.Monad Note [Tracking Given equalities]
      describes how we track when we have Given equalities
    
    * GHC.Tc.Types.Constraint Note [HasGivenEqs]
      is a new explanation of the ic_given_eqs field of an implication
    
    A big raft of subtle Notes in Solver, concerning floatEqualities,
    disappears.
    
    Main code changes:
    
    * GHC.Tc.Solver.floatEqualities disappears entirely
    
    * GHC.Tc.Solver.Monad: new fields in InertCans, inert_given_eq_lvl
      and inert_given_eq, updated by updateGivenEqs
      See Note [Tracking Given equalities].
    
    * In exchange for updateGivenEqa, GHC.Tc.Solver.Monad.getHasGivenEqs
      is much simpler and more efficient
    
    * I found I could kill of metaTyVarUpdateOK entirely
    
    One test case T14683 showed a 5.1% decrease in compile-time
    allocation; and T5631 was down 2.2%. Other changes were small.
    
    Metric Decrease:
        T14683
        T5631
    995a8f9d