Simon Peyton Jones pushed to branch wip/T26115 at Glasgow Haskell Compiler / GHC

Commits:

6 changed files:

Changes:

  • compiler/GHC/Tc/Solver/Dict.hs
    ... ... @@ -2130,7 +2130,8 @@ mk_superclasses_of fuel rec_clss ev tvs theta cls tys
    2130 2130
                         -- NB: If there is a loop, we cut off, so we have not
    
    2131 2131
                         --     added the superclasses, hence cc_pend_sc = fuel
    
    2132 2132
                         | otherwise
    
    2133
    -                    = CQuantCan (QCI { qci_tvs = tvs, qci_body = mkClassPred cls tys
    
    2133
    +                    = CQuantCan (QCI { qci_tvs = tvs, qci_theta = theta
    
    2134
    +                                     , qci_body = mkClassPred cls tys
    
    2134 2135
                                          , qci_ev = ev, qci_pend_sc = fuel })
    
    2135 2136
     
    
    2136 2137
     
    

  • compiler/GHC/Tc/Solver/Equality.hs
    ... ... @@ -10,6 +10,8 @@ module GHC.Tc.Solver.Equality(
    10 10
     
    
    11 11
     import GHC.Prelude
    
    12 12
     
    
    13
    +import {-# SOURCE #-} GHC.Tc.Solver.Solve( trySolveImplication )
    
    14
    +
    
    13 15
     import GHC.Tc.Solver.Irred( solveIrred )
    
    14 16
     import GHC.Tc.Solver.Dict( matchLocalInst, chooseInstance )
    
    15 17
     import GHC.Tc.Solver.Rewrite
    
    ... ... @@ -468,7 +470,7 @@ can_eq_nc_forall :: CtEvidence -> EqRel
    468 470
     -- See Note [Solving forall equalities]
    
    469 471
     
    
    470 472
     can_eq_nc_forall ev eq_rel s1 s2
    
    471
    - | CtWanted (WantedCt { ctev_dest = orig_dest }) <- ev
    
    473
    + | CtWanted (WantedCt { ctev_dest = orig_dest, ctev_loc = loc }) <- ev
    
    472 474
      = do { let (bndrs1, phi1, bndrs2, phi2) = split_foralls s1 s2
    
    473 475
                 flags1 = binderFlags bndrs1
    
    474 476
                 flags2 = binderFlags bndrs2
    
    ... ... @@ -481,9 +483,10 @@ can_eq_nc_forall ev eq_rel s1 s2
    481 483
     
    
    482 484
             else do {
    
    483 485
             traceTcS "Creating implication for polytype equality" (ppr ev)
    
    484
    -      ; let free_tvs     = tyCoVarsOfTypes [s1,s2]
    
    485
    -            empty_subst1 = mkEmptySubst $ mkInScopeSet free_tvs
    
    486
    -      ; skol_info <- mkSkolemInfo (UnifyForAllSkol phi1)
    
    486
    +      ; let free_tvs       = tyCoVarsOfTypes [s1,s2]
    
    487
    +            empty_subst1   = mkEmptySubst $ mkInScopeSet free_tvs
    
    488
    +            skol_info_anon = UnifyForAllSkol phi1
    
    489
    +      ; skol_info <- mkSkolemInfo skol_info_anon
    
    487 490
           ; (subst1, skol_tvs) <- tcInstSkolTyVarsX skol_info empty_subst1 $
    
    488 491
                                   binderVars bndrs1
    
    489 492
     
    
    ... ... @@ -528,10 +531,21 @@ can_eq_nc_forall ev eq_rel s1 s2
    528 531
                                         unifyForAllBody ev (eqRelRole eq_rel) $ \uenv ->
    
    529 532
                                         go uenv skol_tvs init_subst2 bndrs1 bndrs2
    
    530 533
     
    
    531
    -      ; emitTvImplicationTcS lvl (getSkolemInfo skol_info) skol_tvs wanteds
    
    532
    -
    
    533
    -      ; setWantedEq orig_dest all_co
    
    534
    -      ; stopWith ev "Deferred polytype equality" } }
    
    534
    +      ; ev_binds_var <- newNoTcEvBinds
    
    535
    +      ; solved <- trySolveImplication $
    
    536
    +                  (implicationPrototype (ctLocEnv loc))
    
    537
    +                      { ic_tclvl = lvl
    
    538
    +                      , ic_binds = ev_binds_var
    
    539
    +                      , ic_info  = skol_info_anon
    
    540
    +                      , ic_warn_inaccessible = False
    
    541
    +                      , ic_skols = skol_tvs
    
    542
    +                      , ic_given = []
    
    543
    +                      , ic_wanted = emptyWC { wc_simple = wanteds } }
    
    544
    +
    
    545
    +      ; if solved
    
    546
    +        then do { setWantedEq orig_dest all_co
    
    547
    +                ; stopWith ev "Polytype equality: solved" }
    
    548
    +        else canEqSoftFailure IrredShapeReason ev s1 s2 } }
    
    535 549
     
    
    536 550
      | otherwise
    
    537 551
      = do { traceTcS "Omitting decomposition of given polytype equality" $
    
    ... ... @@ -834,18 +848,26 @@ canTyConApp ev eq_rel both_generative (ty1,tc1,tys1) (ty2,tc2,tys2)
    834 848
       = do { inerts <- getInertSet
    
    835 849
            ; if can_decompose inerts
    
    836 850
              then canDecomposableTyConAppOK ev eq_rel tc1 (ty1,tys1) (ty2,tys2)
    
    837
    -         else canEqSoftFailure ev eq_rel ty1 ty2 }
    
    851
    +         else assert (eq_rel == ReprEq) $
    
    852
    +              canEqSoftFailure ReprEqReason ev ty1 ty2 }
    
    838 853
     
    
    839 854
       -- See Note [Skolem abstract data] in GHC.Core.Tycon
    
    840 855
       | tyConSkolem tc1 || tyConSkolem tc2
    
    841 856
       = do { traceTcS "canTyConApp: skolem abstract" (ppr tc1 $$ ppr tc2)
    
    842 857
            ; finishCanWithIrred AbstractTyConReason ev }
    
    843 858
     
    
    844
    -  | otherwise  -- Different TyCons
    
    845
    -  = if both_generative -- See (TC2) and (TC3) in
    
    846
    -                       -- Note [Canonicalising TyCon/TyCon equalities]
    
    847
    -    then canEqHardFailure ev ty1 ty2
    
    848
    -    else canEqSoftFailure ev eq_rel ty1 ty2
    
    859
    +  -- Different TyCons
    
    860
    +  | NomEq <- eq_rel
    
    861
    +  = canEqHardFailure ev ty1 ty2
    
    862
    +
    
    863
    +  -- Different TyCons, eq_rel = ReprEq
    
    864
    +  -- See (TC2) and (TC3) in
    
    865
    +  -- Note [Canonicalising TyCon/TyCon equalities]
    
    866
    +  | both_generative
    
    867
    +  = canEqHardFailure ev ty1 ty2
    
    868
    +
    
    869
    +  | otherwise
    
    870
    +  = canEqSoftFailure ReprEqReason ev ty1 ty2
    
    849 871
       where
    
    850 872
          -- See Note [Decomposing TyConApp equalities]
    
    851 873
          -- and Note [Decomposing newtype equalities]
    
    ... ... @@ -1417,20 +1439,18 @@ canDecomposableFunTy ev eq_rel af f1@(ty1,m1,a1,r1) f2@(ty2,m2,a2,r2)
    1417 1439
     
    
    1418 1440
     -- | Call canEqSoftFailure when canonicalizing an equality fails, but if the
    
    1419 1441
     -- equality is representational, there is some hope for the future.
    
    1420
    -canEqSoftFailure :: CtEvidence -> EqRel -> TcType -> TcType
    
    1442
    +canEqSoftFailure :: CtIrredReason -> CtEvidence -> TcType -> TcType
    
    1421 1443
                      -> TcS (StopOrContinue (Either IrredCt a))
    
    1422
    -canEqSoftFailure ev NomEq ty1 ty2
    
    1423
    -  = canEqHardFailure ev ty1 ty2
    
    1424
    -canEqSoftFailure ev ReprEq ty1 ty2
    
    1444
    +canEqSoftFailure reason ev ty1 ty2
    
    1425 1445
       = do { (redn1, rewriters1) <- rewrite ev ty1
    
    1426 1446
            ; (redn2, rewriters2) <- rewrite ev ty2
    
    1427 1447
                 -- We must rewrite the types before putting them in the
    
    1428 1448
                 -- inert set, so that we are sure to kick them out when
    
    1429 1449
                 -- new equalities become available
    
    1430
    -       ; traceTcS "canEqSoftFailure with ReprEq" $
    
    1450
    +       ; traceTcS "canEqSoftFailure" $
    
    1431 1451
              vcat [ ppr ev, ppr redn1, ppr redn2 ]
    
    1432 1452
            ; new_ev <- rewriteEqEvidence (rewriters1 S.<> rewriters2) ev NotSwapped redn1 redn2
    
    1433
    -       ; finishCanWithIrred ReprEqReason new_ev }
    
    1453
    +       ; finishCanWithIrred reason new_ev }
    
    1434 1454
     
    
    1435 1455
     -- | Call when canonicalizing an equality fails with utterly no hope.
    
    1436 1456
     canEqHardFailure :: CtEvidence -> TcType -> TcType
    

  • compiler/GHC/Tc/Solver/Monad.hs
    ... ... @@ -758,12 +758,14 @@ getUnsolvedInerts
    758 758
                , inert_funeqs  = fun_eqs
    
    759 759
                , inert_irreds  = irreds
    
    760 760
                , inert_dicts   = idicts
    
    761
    +           , inert_insts   = qcis
    
    761 762
                } <- getInertCans
    
    762 763
     
    
    763 764
           ; let unsolved_tv_eqs  = foldTyEqs  (add_if_unsolved CEqCan)    tv_eqs emptyCts
    
    764 765
                 unsolved_fun_eqs = foldFunEqs (add_if_unsolved CEqCan)    fun_eqs emptyCts
    
    765 766
                 unsolved_irreds  = foldr      (add_if_unsolved CIrredCan) emptyCts irreds
    
    766 767
                 unsolved_dicts   = foldDicts  (add_if_unsolved CDictCan)  idicts emptyCts
    
    768
    +            unsolved_qcis    = foldr      (add_if_unsolved CQuantCan) emptyCts qcis
    
    767 769
     
    
    768 770
           ; implics <- getWorkListImplics
    
    769 771
     
    
    ... ... @@ -774,10 +776,11 @@ getUnsolvedInerts
    774 776
                  , text "irreds =" <+> ppr unsolved_irreds
    
    775 777
                  , text "implics =" <+> ppr implics ]
    
    776 778
     
    
    777
    -      ; return ( implics, unsolved_tv_eqs `unionBags`
    
    779
    +      ; return ( implics, unsolved_tv_eqs  `unionBags`
    
    778 780
                               unsolved_fun_eqs `unionBags`
    
    779
    -                          unsolved_irreds `unionBags`
    
    780
    -                          unsolved_dicts ) }
    
    781
    +                          unsolved_irreds  `unionBags`
    
    782
    +                          unsolved_dicts   `unionBags`
    
    783
    +                          unsolved_qcis ) }
    
    781 784
       where
    
    782 785
         add_if_unsolved :: (a -> Ct) -> a -> Cts -> Cts
    
    783 786
         add_if_unsolved mk_ct thing cts
    

  • compiler/GHC/Tc/Solver/Solve.hs
    ... ... @@ -7,6 +7,7 @@ module GHC.Tc.Solver.Solve (
    7 7
          solveWanteds,        -- Solves WantedConstraints
    
    8 8
          solveSimpleGivens,   -- Solves [Ct]
    
    9 9
          solveSimpleWanteds,  -- Solves Cts
    
    10
    +     trySolveImplication,
    
    10 11
     
    
    11 12
          setImplicationStatus
    
    12 13
       ) where
    
    ... ... @@ -1114,14 +1115,15 @@ solveCt (CEqCan (EqCt { eq_ev = ev, eq_eq_rel = eq_rel
    1114 1115
                           , eq_lhs = lhs, eq_rhs = rhs }))
    
    1115 1116
       = solveEquality ev eq_rel (canEqLHSType lhs) rhs
    
    1116 1117
     
    
    1117
    -solveCt (CQuantCan (QCI { qci_ev = ev, qci_pend_sc = pend_sc }))
    
    1118
    -  = do { ev <- rewriteEvidence ev
    
    1118
    +solveCt (CQuantCan qci@(QCI { qci_ev = ev }))
    
    1119
    +  = do { ev' <- rewriteEvidence ev
    
    1119 1120
              -- It is (much) easier to rewrite and re-classify than to
    
    1120 1121
              -- rewrite the pieces and build a Reduction that will rewrite
    
    1121 1122
              -- the whole constraint
    
    1122
    -       ; case classifyPredType (ctEvPred ev) of
    
    1123
    -           ForAllPred tvs theta body_pred ->
    
    1124
    -             Stage $ solveForAll ev tvs theta body_pred pend_sc
    
    1123
    +       ; case classifyPredType (ctEvPred ev') of
    
    1124
    +           ForAllPred tvs theta body_pred
    
    1125
    +             -> solveForAll (qci { qci_ev = ev', qci_tvs = tvs
    
    1126
    +                                 , qci_theta = theta, qci_body = body_pred })
    
    1125 1127
                _ -> pprPanic "SolveCt" (ppr ev) }
    
    1126 1128
     
    
    1127 1129
     solveCt (CDictCan (DictCt { di_ev = ev, di_pend_sc = pend_sc }))
    
    ... ... @@ -1155,7 +1157,7 @@ solveNC ev
    1155 1157
         -- And then re-classify
    
    1156 1158
            ; case classifyPredType (ctEvPred ev) of
    
    1157 1159
                ClassPred cls tys     -> solveDictNC ev cls tys
    
    1158
    -           ForAllPred tvs th p   -> Stage $ solveForAllNC ev tvs th p
    
    1160
    +           ForAllPred tvs th p   -> solveForAllNC ev tvs th p
    
    1159 1161
                IrredPred {}          -> solveIrred (IrredCt { ir_ev = ev, ir_reason = IrredShapeReason })
    
    1160 1162
                EqPred eq_rel ty1 ty2 -> solveEquality ev eq_rel ty1 ty2
    
    1161 1163
                   -- EqPred only happens if (say) `c` is unified with `a ~# b`,
    
    ... ... @@ -1246,51 +1248,49 @@ type signature.
    1246 1248
     --
    
    1247 1249
     -- Precondition: the constraint has already been rewritten by the inert set.
    
    1248 1250
     solveForAllNC :: CtEvidence -> [TcTyVar] -> TcThetaType -> TcPredType
    
    1249
    -              -> TcS (StopOrContinue Void)
    
    1251
    +              -> SolverStage Void
    
    1250 1252
     solveForAllNC ev tvs theta body_pred
    
    1251
    -  | Just (cls,tys) <- getClassPredTys_maybe body_pred
    
    1252
    -  , classHasSCs cls
    
    1253
    -  = do { dflags <- getDynFlags
    
    1254
    -       -- Either expand superclasses (Givens) or provide fuel to do so (Wanteds)
    
    1255
    -       ; if isGiven ev
    
    1256
    -         then
    
    1257
    -           -- See Note [Eagerly expand given superclasses]
    
    1258
    -           -- givensFuel dflags: See Note [Expanding Recursive Superclasses and ExpansionFuel]
    
    1259
    -           do { sc_cts <- mkStrictSuperClasses (givensFuel dflags) ev tvs theta cls tys
    
    1260
    -              ; emitWork (listToBag sc_cts)
    
    1261
    -              ; solveForAll ev tvs theta body_pred doNotExpand }
    
    1262
    -         else
    
    1263
    -           -- See invariants (a) and (b) in QCI.qci_pend_sc
    
    1264
    -           -- qcsFuel dflags: See Note [Expanding Recursive Superclasses and ExpansionFuel]
    
    1265
    -           -- See Note [Quantified constraints]
    
    1266
    -           do { solveForAll ev tvs theta body_pred (qcsFuel dflags) }
    
    1267
    -       }
    
    1253
    +  = do { fuel <- simpleStage mk_super_classes
    
    1254
    +       ; solveForAll (QCI { qci_ev = ev, qci_tvs = tvs, qci_theta = theta
    
    1255
    +                          , qci_body = body_pred, qci_pend_sc = fuel }) }
    
    1268 1256
     
    
    1269
    -  | otherwise
    
    1270
    -  = solveForAll ev tvs theta body_pred doNotExpand
    
    1257
    +  where
    
    1258
    +    mk_super_classes :: TcS ExpansionFuel
    
    1259
    +    mk_super_classes
    
    1260
    +       | Just (cls,tys) <- getClassPredTys_maybe body_pred
    
    1261
    +       , classHasSCs cls
    
    1262
    +       = do { dflags <- getDynFlags
    
    1263
    +            -- Either expand superclasses (Givens) or provide fuel to do so (Wanteds)
    
    1264
    +            ; if isGiven ev
    
    1265
    +              then
    
    1266
    +                -- See Note [Eagerly expand given superclasses]
    
    1267
    +                -- givensFuel dflags: See Note [Expanding Recursive Superclasses and ExpansionFuel]
    
    1268
    +                do { sc_cts <- mkStrictSuperClasses (givensFuel dflags) ev tvs theta cls tys
    
    1269
    +                   ; emitWork (listToBag sc_cts)
    
    1270
    +                   ; return doNotExpand }
    
    1271
    +              else
    
    1272
    +                -- See invariants (a) and (b) in QCI.qci_pend_sc
    
    1273
    +                -- qcsFuel dflags: See Note [Expanding Recursive Superclasses and ExpansionFuel]
    
    1274
    +                -- See Note [Quantified constraints]
    
    1275
    +                return (qcsFuel dflags)
    
    1276
    +            }
    
    1277
    +
    
    1278
    +       | otherwise
    
    1279
    +       = return doNotExpand
    
    1271 1280
     
    
    1272 1281
     -- | Solve a canonical quantified constraint.
    
    1273 1282
     --
    
    1274 1283
     -- Precondition: the constraint has already been rewritten by the inert set.
    
    1275
    -solveForAll :: CtEvidence -> [TcTyVar] -> TcThetaType -> PredType -> ExpansionFuel
    
    1276
    -            -> TcS (StopOrContinue Void)
    
    1277
    -solveForAll ev tvs theta body_pred fuel
    
    1284
    +solveForAll :: QCInst -> SolverStage Void
    
    1285
    +solveForAll qci@(QCI { qci_ev = ev, qci_tvs = tvs, qci_theta = theta, qci_body = pred })
    
    1278 1286
       = case ev of
    
    1279 1287
           CtGiven {} ->
    
    1280 1288
             -- See Note [Solving a Given forall-constraint]
    
    1281
    -        do { addInertForAll qci
    
    1282
    -           ; stopWith ev "Given forall-constraint" }
    
    1289
    +        do { simpleStage (addInertForAll qci)
    
    1290
    +           ; stopWithStage ev "Given forall-constraint" }
    
    1283 1291
           CtWanted wtd ->
    
    1284
    -        do { mode <- getTcSMode
    
    1285
    -           ; case mode of  -- See Note [TcSSpecPrag] in GHC.Tc.Solver.Monad.
    
    1286
    -               TcSSpecPrag -> solveWantedForAll_spec wtd
    
    1287
    -               _           -> runSolverStage $
    
    1288
    -                              do { tryInertQCs qci
    
    1289
    -                                 ; solveWantedForAll_norm wtd tvs theta body_pred } }
    
    1290
    -  where
    
    1291
    -    qci = QCI { qci_ev = ev, qci_tvs = tvs
    
    1292
    -              , qci_body = body_pred, qci_pend_sc = fuel }
    
    1293
    -
    
    1292
    +        do { tryInertQCs qci
    
    1293
    +           ; solveWantedForAll qci tvs theta pred wtd }
    
    1294 1294
     
    
    1295 1295
     tryInertQCs :: QCInst -> SolverStage ()
    
    1296 1296
     tryInertQCs qc
    
    ... ... @@ -1316,11 +1316,11 @@ try_inert_qcs (QCI { qci_ev = ev_w }) inerts =
    1316 1316
     
    
    1317 1317
     -- | Solve a (canonical) Wanted quantified constraint by emitting an implication.
    
    1318 1318
     -- See Note [Solving a Wanted forall-constraint]
    
    1319
    -solveWantedForAll_norm :: WantedCtEvidence -> [TcTyVar] -> TcThetaType -> PredType
    
    1320
    -                       -> SolverStage Void
    
    1321
    -solveWantedForAll_norm wtd@(WantedCt { ctev_dest = dest, ctev_loc = ct_loc
    
    1322
    -                                     , ctev_rewriters = rewriters })
    
    1323
    -                  tvs theta body_pred
    
    1319
    +solveWantedForAll :: QCInst -> [TcTyVar] -> TcThetaType -> PredType
    
    1320
    +                  -> WantedCtEvidence -> SolverStage Void
    
    1321
    +solveWantedForAll qci tvs theta body_pred
    
    1322
    +                  wtd@(WantedCt { ctev_dest = dest, ctev_loc = ct_loc
    
    1323
    +                                , ctev_rewriters = rewriters })
    
    1324 1324
       = Stage $
    
    1325 1325
         TcS.setSrcSpan (getCtLocEnvLoc loc_env) $
    
    1326 1326
              -- This setSrcSpan is important: the emitImplicationTcS uses that
    
    ... ... @@ -1349,27 +1349,25 @@ solveWantedForAll_norm wtd@(WantedCt { ctev_dest = dest, ctev_loc = ct_loc
    1349 1349
                                  , unitBag (mkNonCanonical $ CtWanted wanted_ev)) }
    
    1350 1350
     
    
    1351 1351
            ; traceTcS "solveForAll" (ppr given_ev_vars $$ ppr wanteds $$ ppr w_id)
    
    1352
    -       ; ev_binds_var <- newTcEvBinds
    
    1352
    +       ; ev_binds_var <- TcS.newTcEvBinds
    
    1353 1353
            ; solved <- trySolveImplication $
    
    1354
    -                   implicationPrototype loc_env
    
    1354
    +                   (implicationPrototype loc_env)
    
    1355 1355
                           { ic_tclvl = lvl
    
    1356 1356
                           , ic_binds = ev_binds_var
    
    1357 1357
                           , ic_info  = skol_info_anon
    
    1358
    -                      , ic_warn_inacessible = False
    
    1358
    +                      , ic_warn_inaccessible = False
    
    1359 1359
                           , ic_skols = skol_tvs
    
    1360 1360
                           , ic_given = given_ev_vars
    
    1361 1361
                           , ic_wanted = emptyWC { wc_simple = wanteds } }
    
    1362 1362
            ; if not solved
    
    1363
    -         then updInertIrreds (
    
    1364
    -         else
    
    1365
    -    do { ev_binds <- emitImplicationTcS lvl skol_info_anon skol_tvs given_ev_vars wanteds
    
    1366
    -
    
    1367
    -       ; setWantedEvTerm dest EvCanonical $
    
    1368
    -         EvFun { et_tvs = skol_tvs, et_given = given_ev_vars
    
    1369
    -               , et_binds = ev_binds, et_body = w_id }
    
    1370
    -       ; stopWith (CtWanted wtd) "Wanted forall-constraint (implication)" }
    
    1363
    +         then do { addInertForAll qci
    
    1364
    +                 ; stopWith (CtWanted wtd) "Wanted forall-constraint:unsolved" }
    
    1365
    +         else do { setWantedEvTerm dest EvCanonical $
    
    1366
    +                   EvFun { et_tvs = skol_tvs, et_given = given_ev_vars
    
    1367
    +                         , et_binds = TcEvBinds ev_binds_var, et_body = w_id }
    
    1368
    +                 ; stopWith (CtWanted wtd) "Wanted forall-constraint:solved" } }
    
    1371 1369
       where
    
    1372
    -    loc_env = ctLocEnv loc
    
    1370
    +    loc_env = ctLocEnv ct_loc
    
    1373 1371
         is_qc = IsQC (ctLocOrigin ct_loc)
    
    1374 1372
     
    
    1375 1373
         empty_subst = mkEmptySubst $ mkInScopeSet $
    
    ... ... @@ -1381,6 +1379,14 @@ solveWantedForAll_norm wtd@(WantedCt { ctev_dest = dest, ctev_loc = ct_loc
    1381 1379
                           ClassPred cls tys -> pSizeClassPred cls tys
    
    1382 1380
                           _                 -> pSizeType pred
    
    1383 1381
     
    
    1382
    +trySolveImplication :: Implication -> TcS Bool
    
    1383
    +trySolveImplication imp
    
    1384
    +  = tryTcS $
    
    1385
    +    do { imp' <- solveImplication imp
    
    1386
    +       ; return (emptyWC { wc_impl = unitBag imp' }) }
    
    1387
    +         -- ToDo: this emptyWC bit is somewhat clumsy
    
    1388
    +
    
    1389
    +{-
    
    1384 1390
     solveWantedForAll_spec :: WantedCtEvidence -> TcS (StopOrContinue Void)
    
    1385 1391
     -- Solve this implication constraint completely or not at all
    
    1386 1392
     solveWantedForAll_spec wtd
    
    ... ... @@ -1399,7 +1405,7 @@ solveWantedForAll_spec wtd
    1399 1405
                      ; return $ Stop ev (text "Not fully solved:" <+> ppr wtd) } }
    
    1400 1406
       where
    
    1401 1407
         ev = CtWanted wtd
    
    1402
    -
    
    1408
    +-}
    
    1403 1409
     
    
    1404 1410
     {- Note [Solving a Wanted forall-constraint]
    
    1405 1411
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

  • compiler/GHC/Tc/Solver/Solve.hs-boot
    1 1
     module GHC.Tc.Solver.Solve where
    
    2 2
     
    
    3
    +import Prelude( Bool )
    
    3 4
     import GHC.Tc.Solver.Monad( TcS )
    
    4
    -import GHC.Tc.Types.Constraint( WantedConstraints, Cts )
    
    5
    +import GHC.Tc.Types.Constraint( WantedConstraints, Cts, Implication )
    
    5 6
     
    
    6
    -solveSimpleWanteds :: Cts -> TcS WantedConstraints
    \ No newline at end of file
    7
    +solveSimpleWanteds :: Cts -> TcS WantedConstraints
    
    8
    +trySolveImplication :: Implication -> TcS Bool

  • compiler/GHC/Tc/Types/Constraint.hs
    ... ... @@ -351,9 +351,10 @@ instance Outputable IrredCt where
    351 351
     -- See Note [Quantified constraints] in GHC.Tc.Solver.Solve
    
    352 352
     data QCInst
    
    353 353
       -- | A quantified constraint, of type @forall tvs. context => ty@
    
    354
    -  = QCI { qci_ev   :: CtEvidence
    
    355
    -        , qci_tvs  :: [TcTyVar]  -- ^ @tvs@
    
    356
    -        , qci_body :: TcPredType -- ^ the body of the @forall@, i.e. @ty@
    
    354
    +  = QCI { qci_ev    :: CtEvidence -- See Note [Ct/evidence invariant]
    
    355
    +        , qci_tvs   :: [TcTyVar]  -- ^ @tvs@
    
    356
    +        , qci_theta :: TcThetaType
    
    357
    +        , qci_body  :: TcPredType -- ^ the body of the @forall@, i.e. @ty@
    
    357 358
             , qci_pend_sc :: ExpansionFuel
    
    358 359
                  -- ^ Invariants: qci_pend_sc > 0 =>
    
    359 360
                  --
    
    ... ... @@ -990,8 +991,8 @@ pendingScDict_maybe _ = Nothing
    990 991
     
    
    991 992
     pendingScInst_maybe :: QCInst -> Maybe QCInst
    
    992 993
     -- Same as isPendingScDict, but for QCInsts
    
    993
    -pendingScInst_maybe qci@(QCI { qci_flav = flav, qci_pend_sc = f })
    
    994
    -  | Given <- flav -- Do not expand Wanted QCIs
    
    994
    +pendingScInst_maybe qci@(QCI { qci_ev = ev, qci_pend_sc = f })
    
    995
    +  | isGiven ev -- Do not expand Wanted QCIs
    
    995 996
       , pendingFuel f = Just (qci { qci_pend_sc = doNotExpand })
    
    996 997
       | otherwise     = Nothing
    
    997 998