Simon Peyton Jones pushed to branch wip/T23162-part2 at Glasgow Haskell Compiler / GHC

Commits:

6 changed files:

Changes:

  • compiler/GHC/Tc/Solver/Default.hs
    ... ... @@ -508,6 +508,10 @@ defaultEquality encl_eqs ct
    508 508
       = return False
    
    509 509
     
    
    510 510
       where
    
    511
    +    ev  = ctEvidence ct
    
    512
    +    rws = ctEvRewriters ev
    
    513
    +    loc = ctEvLoc ev
    
    514
    +
    
    511 515
         -- try_default_tv_nom: used for tv ~#N ty
    
    512 516
         try_default_tv_nom lhs_tv rhs_ty
    
    513 517
           | MetaTv { mtv_info = info } <- tcTyVarDetails lhs_tv
    
    ... ... @@ -546,7 +550,7 @@ defaultEquality encl_eqs ct
    546 550
               = do { traceTcS "defaultEquality success:" (ppr rhs_ty)
    
    547 551
                    ; unifyTyVar lhs_tv rhs_ty  -- NB: unifyTyVar adds to the
    
    548 552
                                                -- TcS unification counter
    
    549
    -               ; setEqIfWanted (ctEvidence ct) (mkReflCPH NomEq rhs_ty)
    
    553
    +               ; setEqIfWanted ev (mkReflCPH NomEq rhs_ty)
    
    550 554
                    ; return True
    
    551 555
                    }
    
    552 556
     
    
    ... ... @@ -561,7 +565,7 @@ defaultEquality encl_eqs ct
    561 565
                 -- This handles cases such as @IO alpha[tau] ~R# IO Int@
    
    562 566
                 -- by defaulting @alpha := Int@, which is useful in practice
    
    563 567
                 -- (see Note [Defaulting representational equalities]).
    
    564
    -           ; (co, new_eqs) <- wrapUnifier (ctEvidence ct) Nominal $ \uenv ->
    
    568
    +           ; (co, new_eqs) <- wrapUnifier rws loc Nominal $ \uenv ->
    
    565 569
                                   -- NB: nominal equality!
    
    566 570
                                   uType uenv z_ty1 z_ty2
    
    567 571
     
    
    ... ... @@ -571,7 +575,7 @@ defaultEquality encl_eqs ct
    571 575
                 -- See Note [Defaulting representational equalities].
    
    572 576
                ; if null new_eqs
    
    573 577
                  then do { traceTcS "defaultEquality ReprEq } (yes)" empty
    
    574
    -                     ; setEqIfWanted (ctEvidence ct) $
    
    578
    +                     ; setEqIfWanted ev $
    
    575 579
                            CPH { cph_co = mkSubCo co, cph_holes = emptyCoHoleSet }
    
    576 580
                          ; return True }
    
    577 581
                  else do { traceTcS "defaultEquality ReprEq } (no)" empty
    

  • compiler/GHC/Tc/Solver/Dict.hs
    ... ... @@ -4,7 +4,6 @@
    4 4
     -- | Solving Class constraints CDictCan
    
    5 5
     module GHC.Tc.Solver.Dict (
    
    6 6
       solveDict, solveDictNC, solveCallStack,
    
    7
    -  checkInstanceOK,
    
    8 7
       matchLocalInst, chooseInstance,
    
    9 8
       makeSuperClasses, mkStrictSuperClasses
    
    10 9
       ) where
    
    ... ... @@ -857,8 +856,22 @@ chooseInstance work_item@(WantedCt { ctev_dest = dest, ctev_rewriters = rws
    857 856
                             , cir_mk_ev       = mk_ev
    
    858 857
                             , cir_canonical   = canonical })
    
    859 858
       = do { traceTcS "doTopReact/found instance for" $ ppr work_item
    
    860
    -       ; deeper_loc <- checkInstanceOK loc what pred
    
    861
    -       ; checkReductionDepth deeper_loc pred
    
    859
    +
    
    860
    +      -- Check that the dfun is well-staged in the Template Haskell sense
    
    861
    +       ; checkWellLevelledDFun loc what pred
    
    862
    +
    
    863
    +       -- zapped_loc: after applying an instance we can set ScOrigin to
    
    864
    +       -- NotNakedSc, so that prohibitedSuperClassSolve never fires
    
    865
    +       -- See Note [Solving superclass constraints] in
    
    866
    +       -- GHC.Tc.TyCl.Instance, (sc1).
    
    867
    +       ; let zapped_loc | ScOrigin what _ <- ctLocOrigin loc
    
    868
    +                        = setCtLocOrigin loc (ScOrigin what NotNakedSc)
    
    869
    +                        | otherwise
    
    870
    +                        = loc
    
    871
    +
    
    872
    +       -- Deeper location for new constraints
    
    873
    +       ; deeper_loc <- bumpReductionDepth zapped_loc pred
    
    874
    +
    
    862 875
            ; assertPprM (getTcEvBindsVar >>= return . not . isCoEvBindsVar)
    
    863 876
                         (ppr work_item)
    
    864 877
            ; evc_vars <- mapM (newWanted deeper_loc rws) theta
    
    ... ... @@ -868,27 +881,6 @@ chooseInstance work_item@(WantedCt { ctev_dest = dest, ctev_rewriters = rws
    868 881
     chooseInstance work_item lookup_res
    
    869 882
       = pprPanic "chooseInstance" (ppr work_item $$ ppr lookup_res)
    
    870 883
     
    
    871
    -checkInstanceOK :: CtLoc -> InstanceWhat -> TcPredType -> TcS CtLoc
    
    872
    --- Check that it's OK to use this instance:
    
    873
    ---    (a) the use is well staged in the Template Haskell sense
    
    874
    --- Returns the CtLoc to used for sub-goals
    
    875
    --- Probably also want to call checkReductionDepth
    
    876
    -checkInstanceOK loc what pred
    
    877
    -  = do { checkWellLevelledDFun loc what pred
    
    878
    -       ; return deeper_loc }
    
    879
    -  where
    
    880
    -     deeper_loc = zap_origin (bumpCtLocDepth loc)
    
    881
    -     origin     = ctLocOrigin loc
    
    882
    -
    
    883
    -     zap_origin loc  -- After applying an instance we can set ScOrigin to
    
    884
    -                     -- NotNakedSc, so that prohibitedSuperClassSolve never fires
    
    885
    -                     -- See Note [Solving superclass constraints] in
    
    886
    -                     -- GHC.Tc.TyCl.Instance, (sc1).
    
    887
    -       | ScOrigin what _ <- origin
    
    888
    -       = setCtLocOrigin loc (ScOrigin what NotNakedSc)
    
    889
    -       | otherwise
    
    890
    -       = loc
    
    891
    -
    
    892 884
     matchClassInst :: DynFlags -> InertSet
    
    893 885
                    -> Class -> [Type]
    
    894 886
                    -> CtLoc -> TcS ClsInstResult
    

  • compiler/GHC/Tc/Solver/Equality.hs
    ... ... @@ -486,7 +486,7 @@ can_eq_nc_forall :: CtEvidence -> EqRel
    486 486
     -- See Note [Solving forall equalities]
    
    487 487
     
    
    488 488
     can_eq_nc_forall ev eq_rel s1 s2
    
    489
    - | CtWanted (WantedCt { ctev_dest = orig_dest }) <- ev
    
    489
    + | CtWanted (WantedCt { ctev_dest = orig_dest, ctev_rewriters = rws, ctev_loc = loc }) <- ev
    
    490 490
      = do { let (bndrs1, phi1, bndrs2, phi2) = split_foralls s1 s2
    
    491 491
                 flags1 = binderFlags bndrs1
    
    492 492
                 flags2 = binderFlags bndrs2
    
    ... ... @@ -550,7 +550,7 @@ can_eq_nc_forall ev eq_rel s1 s2
    550 550
                     do { -- Generate constraints
    
    551 551
                          (tclvl, (all_co, wanteds))
    
    552 552
                               <- pushLevelNoWorkList (ppr skol_info) $
    
    553
    -                             wrapUnifier ev (eqRelRole eq_rel)   $ \uenv ->
    
    553
    +                             wrapUnifier rws loc (eqRelRole eq_rel)   $ \uenv ->
    
    554 554
                                  go uenv skol_tvs init_subst2 bndrs1 bndrs2
    
    555 555
     
    
    556 556
                        ; traceTcS "Trying to solve the implication" (ppr s1 $$ ppr s2 $$ ppr wanteds)
    
    ... ... @@ -788,9 +788,8 @@ can_eq_newtype_nc rdr_env envs ev swapped ty1 ((gres, co1), ty1') ty2 ps_ty2
    788 788
     
    
    789 789
              -- Check for blowing our stack, and increase the depth
    
    790 790
              -- See Note [Newtypes can blow the stack]
    
    791
    -       ; let loc = ctEvLoc ev
    
    792
    -             ev' = ev `setCtEvLoc` bumpCtLocDepth loc
    
    793
    -       ; checkReductionDepth loc ty1
    
    791
    +       ; loc' <- bumpReductionDepth (ctEvLoc ev) ty1
    
    792
    +       ; let ev' = ev `setCtEvLoc` loc'
    
    794 793
     
    
    795 794
              -- Next, we record uses of newtype constructors, since coercing
    
    796 795
              -- through newtypes is tantamount to using their constructors.
    
    ... ... @@ -1689,9 +1688,9 @@ canEqCanLHSHetero ev eq_rel swapped lhs1 ps_xi1 ki1 xi2 ps_xi2 ki2
    1689 1688
                   ; emitWorkNC [CtGiven kind_ev]
    
    1690 1689
                   ; finish emptyCoHoleSet (givenCtEvCoercion kind_ev) }
    
    1691 1690
     
    
    1692
    -      CtWanted {}
    
    1691
    +      CtWanted (WantedCt { ctev_loc = loc, ctev_rewriters = rws })
    
    1693 1692
              -> do { (unifs, (kind_co, eqs)) <- reportFineGrainUnifications $
    
    1694
    -                                            wrapUnifier ev Nominal $ \uenv ->
    
    1693
    +                                            wrapUnifier rws loc Nominal $ \uenv ->
    
    1695 1694
                                                 let uenv' = updUEnvLoc uenv (mkKindEqLoc xi1 xi2)
    
    1696 1695
                                                 in uType uenv' ki2 ki1
    
    1697 1696
                           -- kind_co :: ki2 ~N ki1
    

  • compiler/GHC/Tc/Solver/FunDeps.hs
    ... ... @@ -25,7 +25,6 @@ import GHC.Core.FamInstEnv
    25 25
     import GHC.Core.Coercion
    
    26 26
     import GHC.Core.Predicate( EqRel(..) )
    
    27 27
     import GHC.Core.TyCon
    
    28
    -import GHC.Core.TyCo.Rep( Type(..) )
    
    29 28
     import GHC.Core.Unify( tcUnifyTysForInjectivity, typeListsAreApart )
    
    30 29
     import GHC.Core.Coercion.Axiom
    
    31 30
     import GHC.Core.TyCo.Subst( elemSubst )
    
    ... ... @@ -36,7 +35,6 @@ import GHC.Types.Var.Set
    36 35
     
    
    37 36
     import GHC.Utils.Outputable
    
    38 37
     import GHC.Utils.Panic
    
    39
    -import GHC.Utils.Misc( lengthExceeds )
    
    40 38
     
    
    41 39
     import GHC.Data.Pair
    
    42 40
     import Data.Maybe( isNothing, isJust, mapMaybe )
    
    ... ... @@ -545,25 +543,11 @@ tryFDEqns fam_tc work_args work_item@(EqCt { eq_ev = ev, eq_rhs= rhs }) mk_fd_eq
    545 543
     -----------------------------------------
    
    546 544
     mkTopClosedFamEqFDs :: CoAxiom Branched -> [TcType] -> Xi -> TcS [FunDepEqns]
    
    547 545
     mkTopClosedFamEqFDs ax work_args work_rhs
    
    548
    -  | isInformativeType work_rhs   -- Does RHS have anything useful to say?
    
    549 546
       = do { let branches = fromBranches (coAxiomBranches ax)
    
    550 547
            ; traceTcS "mkTopClosed" (ppr branches $$ ppr work_args $$ ppr work_rhs)
    
    551 548
            ; case getRelevantBranches ax work_args work_rhs of
    
    552 549
                [eqn] -> return [eqn]  -- If there is just one relevant equation, use it
    
    553 550
                _     -> return [] }
    
    554
    -   | otherwise
    
    555
    -   = return []
    
    556
    -
    
    557
    -isInformativeType :: Type -> Bool
    
    558
    --- The type is headed by something generative, not just
    
    559
    --- a type variable or a type-family application
    
    560
    -isInformativeType ty | Just ty' <- coreView ty = isInformativeType ty'
    
    561
    -isInformativeType (CastTy ty _)                = isInformativeType ty
    
    562
    -isInformativeType (TyVarTy {})                 = False
    
    563
    -isInformativeType (CoercionTy {})              = False  -- Moot
    
    564
    -isInformativeType (TyConApp tc tys)            = isGenerativeTyCon tc Nominal ||
    
    565
    -                                                 tys `lengthExceeds` tyConArity tc
    
    566
    -isInformativeType _ = True  -- AppTy, ForAllTy, FunTy, LitTy
    
    567 551
     
    
    568 552
     hasRelevantGiven :: [EqCt] -> [TcType] -> EqCt -> Bool
    
    569 553
     -- A Given is relevant if it is not apart from the Wanted
    
    ... ... @@ -907,14 +891,17 @@ solveFunDeps work_ev fd_eqns
    907 891
       = return False -- Common case no-op
    
    908 892
     
    
    909 893
       | otherwise
    
    910
    -  = do { (unifs, _res)
    
    894
    +  = do { loc' <- bumpReductionDepth (ctEvLoc work_ev) (ctEvPred work_ev)
    
    895
    +
    
    896
    +       ; (unifs, _res)
    
    911 897
                  <- reportFineGrainUnifications $
    
    912 898
                     nestFunDepsTcS              $
    
    913 899
                     TcS.pushTcLevelM_           $
    
    914 900
                        -- pushTcLevelTcM: increase the level so that unification variables
    
    915 901
                        -- allocated by the fundep-creation itself don't count as useful unifications
    
    916 902
                        -- See Note [Deeper TcLevel for partial improvement unification variables]
    
    917
    -                do { (_, eqs) <- wrapUnifier work_ev Nominal do_fundeps
    
    903
    +                do { (_, eqs) <- wrapUnifier (ctEvRewriters work_ev) loc' Nominal $
    
    904
    +                                 do_fundeps
    
    918 905
                        ; solveSimpleWanteds eqs }
    
    919 906
         -- Why solveSimpleWanteds?  Answer
    
    920 907
         --     (a) We don't want to rely on the eager unifier being clever
    
    ... ... @@ -938,7 +925,7 @@ instantiateFunDepEqns (FDEqns { fd_qtvs = tvs, fd_eqs = eqs })
    938 925
       | null tvs
    
    939 926
       = return rev_eqs
    
    940 927
       | otherwise
    
    941
    -  = do { TcM.traceTc "emitFunDepWanteds 2" (ppr tvs $$ ppr eqs)
    
    928
    +  = do { TcM.traceTc "instantiateFunDepEqns" (ppr tvs $$ ppr eqs)
    
    942 929
            ; (_, subst) <- instFlexiXTcM emptySubst tvs  -- Takes account of kind substitution
    
    943 930
            ; return (map (subst_pair subst) rev_eqs) }
    
    944 931
       where
    

  • compiler/GHC/Tc/Solver/Monad.hs
    ... ... @@ -58,7 +58,7 @@ module GHC.Tc.Solver.Monad (
    58 58
         setEvBind, setWantedEq, setWantedDict, setEqIfWanted, setDictIfWanted,
    
    59 59
         fillCoercionHole,
    
    60 60
         newEvVar, newGivenEv, emitNewGivens,
    
    61
    -    emitChildEqs, checkReductionDepth,
    
    61
    +    emitChildEqs, bumpReductionDepth,
    
    62 62
     
    
    63 63
         getInstEnvs, getFamInstEnvs,                -- Getting the environments
    
    64 64
         getTopEnv, getGblEnv, getLclEnv, setSrcSpan,
    
    ... ... @@ -1810,8 +1810,6 @@ selectNextWorkItem
    1810 1810
                  pick_me ct new_wl
    
    1811 1811
                    = do { writeTcRef wl_var new_wl
    
    1812 1812
                         ; return (Just ct) }
    
    1813
    -                 -- NB: no need for checkReductionDepth (ctLoc ct) (ctPred ct)
    
    1814
    -                 -- This is done by GHC.Tc.Solver.Dict.chooseInstance
    
    1815 1813
     
    
    1816 1814
                  -- try_rws looks through rw_eqs to find one that has an empty
    
    1817 1815
                  -- rewriter set, after zonking.  If none such, call try_rest.
    
    ... ... @@ -2184,12 +2182,13 @@ newWantedNC loc rewriters pty
    2184 2182
     
    
    2185 2183
     -- | Checks if the depth of the given location is too much. Fails if
    
    2186 2184
     -- it's too big, with an appropriate error message.
    
    2187
    -checkReductionDepth :: CtLoc -> TcType   -- ^ type being reduced
    
    2188
    -                    -> TcS ()
    
    2189
    -checkReductionDepth loc ty
    
    2185
    +bumpReductionDepth :: CtLoc -> TcType   -- ^ type being reduced
    
    2186
    +                   -> TcS CtLoc
    
    2187
    +bumpReductionDepth loc ty
    
    2190 2188
       = do { dflags <- getDynFlags
    
    2191 2189
            ; when (subGoalDepthExceeded (reductionDepth dflags) (ctLocDepth loc)) $
    
    2192
    -         wrapErrTcS $ solverDepthError loc ty }
    
    2190
    +         wrapErrTcS $ solverDepthError loc ty
    
    2191
    +       ; return (bumpCtLocDepth loc) }
    
    2193 2192
     
    
    2194 2193
     matchFam :: TyCon -> [Type] -> TcS (Maybe ReductionN)
    
    2195 2194
     matchFam tycon args = wrapTcS $ matchFamTcM tycon args
    
    ... ... @@ -2258,7 +2257,8 @@ wrapUnifierAndEmit :: CtEvidence -> Role
    2258 2257
     --    returns a CoHoleSet describing the new unsolved goals
    
    2259 2258
     wrapUnifierAndEmit ev role do_unifications
    
    2260 2259
       = do { (unifs, (co, eqs)) <- reportFineGrainUnifications $
    
    2261
    -                               wrapUnifier ev role do_unifications
    
    2260
    +                               wrapUnifier (ctEvRewriters ev) (ctEvLoc ev) role $
    
    2261
    +                               do_unifications
    
    2262 2262
     
    
    2263 2263
            -- Emit the deferred constraints
    
    2264 2264
            ; emitChildEqs ev eqs
    
    ... ... @@ -2268,7 +2268,7 @@ wrapUnifierAndEmit ev role do_unifications
    2268 2268
     
    
    2269 2269
            ; return (CPH { cph_co = co, cph_holes = rewriterSetFromCts eqs }) }
    
    2270 2270
     
    
    2271
    -wrapUnifier :: CtEvidence -> Role
    
    2271
    +wrapUnifier :: CoHoleSet -> CtLoc -> Role
    
    2272 2272
                  -> (UnifyEnv -> TcM a)  -- Some calls to uType
    
    2273 2273
                  -> TcS (a, Bag Ct)
    
    2274 2274
     -- Invokes the do_unifications argument, with a suitable UnifyEnv.
    
    ... ... @@ -2276,7 +2276,7 @@ wrapUnifier :: CtEvidence -> Role
    2276 2276
     --    See Note [wrapUnifier]
    
    2277 2277
     -- The (Bag Ct) are the deferred constraints; we emit them but
    
    2278 2278
     -- also return them
    
    2279
    -wrapUnifier ev role do_unifications
    
    2279
    +wrapUnifier rws loc role do_unifications
    
    2280 2280
       = do { given_eq_lvl <- getInnermostGivenEqLevel
    
    2281 2281
            ; what_uni     <- getWhatUnifications
    
    2282 2282
     
    
    ... ... @@ -2284,8 +2284,8 @@ wrapUnifier ev role do_unifications
    2284 2284
              do { defer_ref    <- TcM.newTcRef emptyBag
    
    2285 2285
                 ; let env = UE { u_role         = role
    
    2286 2286
                                , u_given_eq_lvl = given_eq_lvl
    
    2287
    -                           , u_rewriters    = ctEvRewriters ev
    
    2288
    -                           , u_loc          = ctEvLoc ev
    
    2287
    +                           , u_rewriters    = rws
    
    2288
    +                           , u_loc          = loc
    
    2289 2289
                                , u_defer        = defer_ref
    
    2290 2290
                                , u_what         = what_uni }
    
    2291 2291
                   -- u_rewriters: the rewriter set and location from
    

  • compiler/GHC/Tc/Solver/Rewrite.hs
    ... ... @@ -11,7 +11,7 @@ import GHC.Tc.Types ( TcGblEnv(tcg_tc_plugin_rewriters),
    11 11
                           RewriteEnv(..),
    
    12 12
                           runTcPluginM )
    
    13 13
     import GHC.Tc.Types.Constraint
    
    14
    -import GHC.Tc.Types.CtLoc( CtLoc, bumpCtLocDepth )
    
    14
    +import GHC.Tc.Types.CtLoc( CtLoc )
    
    15 15
     import GHC.Core.Predicate
    
    16 16
     import GHC.Tc.Utils.TcType
    
    17 17
     import GHC.Core.Type
    
    ... ... @@ -125,14 +125,6 @@ getFlavourRole
    125 125
            ; eq_rel <- getEqRel
    
    126 126
            ; return (flavour, eq_rel) }
    
    127 127
     
    
    128
    -getLoc :: RewriteM CtLoc
    
    129
    -getLoc = getRewriteEnvField re_loc
    
    130
    -
    
    131
    -checkStackDepth :: Type -> RewriteM ()
    
    132
    -checkStackDepth ty
    
    133
    -  = do { loc <- getLoc
    
    134
    -       ; liftTcS $ checkReductionDepth loc ty }
    
    135
    -
    
    136 128
     -- | Change the 'EqRel' in a 'RewriteM'.
    
    137 129
     setEqRel :: EqRel -> RewriteM a -> RewriteM a
    
    138 130
     setEqRel new_eq_rel thing_inside
    
    ... ... @@ -142,12 +134,13 @@ setEqRel new_eq_rel thing_inside
    142 134
         else runRewriteM thing_inside (env { re_eq_rel = new_eq_rel })
    
    143 135
     {-# INLINE setEqRel #-}
    
    144 136
     
    
    145
    -bumpDepth :: RewriteM a -> RewriteM a
    
    146
    -bumpDepth (RewriteM thing_inside)
    
    137
    +bumpReductionDepthRM :: Type -> RewriteM a -> RewriteM a
    
    138
    +bumpReductionDepthRM ty (RewriteM thing_inside)
    
    147 139
       = mkRewriteM $ \env -> do
    
    148
    -      -- bumpDepth can be called a lot during rewriting so we force the
    
    149
    -      -- new env to avoid accumulating thunks.
    
    150
    -      { let !env' = env { re_loc = bumpCtLocDepth (re_loc env) }
    
    140
    +      { loc' <- TcS.bumpReductionDepth (re_loc env) ty
    
    141
    +      ; let !env' = env { re_loc = loc' }
    
    142
    +            -- !env: bumpReductionDepth can be called a lot during rewriting
    
    143
    +            -- so we force the new env to avoid accumulating thunks
    
    151 144
           ; thing_inside env' }
    
    152 145
     
    
    153 146
     recordRewriter :: CtEvidence -> RewriteM ()
    
    ... ... @@ -584,7 +577,7 @@ rewrite_co co = liftTcS $ zonkCo co
    584 577
     -- | Rewrite a reduction, composing the resulting coercions.
    
    585 578
     rewrite_reduction :: Reduction -> RewriteM Reduction
    
    586 579
     rewrite_reduction (Reduction co xi)
    
    587
    -  = do { redn <- bumpDepth $ rewrite_one xi
    
    580
    +  = do { redn <- rewrite_one xi
    
    588 581
            ; return $ co `mkTransRedn` redn }
    
    589 582
     
    
    590 583
     -- rewrite (nested) AppTys
    
    ... ... @@ -799,10 +792,9 @@ rewrite_fam_app tc tys -- Can be over-saturated
    799 792
     -- See Note [How to normalise a family application]
    
    800 793
     rewrite_exact_fam_app :: TyCon -> [TcType] -> RewriteM Reduction
    
    801 794
     rewrite_exact_fam_app tc tys
    
    802
    -  = do { checkStackDepth (mkTyConApp tc tys)
    
    803
    -
    
    804
    -       -- Query the typechecking plugins for all their rewriting functions
    
    805
    -       -- which apply to a type family application headed by the TyCon 'tc'.
    
    795
    +  = bumpReductionDepthRM (mkTyConApp tc tys) $
    
    796
    +    do { -- Query the typechecking plugins for all their rewriting functions
    
    797
    +         -- which apply to a type family application headed by the TyCon 'tc'.
    
    806 798
            ; tc_rewriters <- getTcPluginRewritersForTyCon tc
    
    807 799
     
    
    808 800
            -- STEP 1. Try to reduce without reducing arguments first.