| ... |
... |
@@ -2294,23 +2294,18 @@ canEqCanLHSFinish_no_unification ev eq_rel swapped lhs rhs |
|
2294
|
2294
|
-- If we had F a ~ G (F a), which gives an occurs check,
|
|
2295
|
2295
|
-- then swap it to G (F a) ~ F a, which does not
|
|
2296
|
2296
|
-- See Note [Orienting TyVarLHS/TyFamLHS]
|
|
2297
|
|
- -- ToDo: fix me
|
|
|
2297
|
+ -- ToDo: fix me ... also needed for a ~ G (F a)
|
|
2298
|
2298
|
-- However `swap_for_size` above will orient it with (G (F a)) on
|
|
2299
|
2299
|
-- the left anwyway. `swap_for_rewriting` "wins", but that doesn't
|
|
2300
|
2300
|
-- matter: in the occurs check case swap_for_rewriting will be moot.
|
|
2301
|
2301
|
-- TL;DR: the next four lines of code are redundant
|
|
2302
|
2302
|
-- I'm leaving them here in case they become relevant again
|
|
2303
|
|
- | TyFamLHS {} <- lhs
|
|
2304
|
|
- , Just can_rhs <- canTyFamEqLHS_maybe rhs
|
|
|
2303
|
+ | Just can_rhs <- canTyFamEqLHS_maybe rhs
|
|
2305
|
2304
|
, reason `cterHasOnlyProblem` cteSolubleOccurs
|
|
2306
|
|
- -> swapAndFinish ev eq_rel swapped lhs_ty can_rhs
|
|
|
2305
|
+ -> finishWith ev eq_rel (flipSwap swapped) can_rhs lhs_ty
|
|
2307
|
2306
|
|
|
2308
|
2307
|
| reason `cterHasOnlyProblems` do_not_prevent_rewriting
|
|
2309
|
|
- -> do { new_ev <- rewriteEqEvidenceSwapOnly ev eq_rel swapped lhs rhs
|
|
2310
|
|
- ; continueWith $ Right $
|
|
2311
|
|
- EqCt { eq_ev = new_ev, eq_eq_rel = eq_rel
|
|
2312
|
|
- , eq_lhs = lhs , eq_rhs = rhs }
|
|
2313
|
|
- }
|
|
|
2308
|
+ -> finishWith ev eq_rel swapped lhs rhs
|
|
2314
|
2309
|
|
|
2315
|
2310
|
| otherwise
|
|
2316
|
2311
|
-> tryIrredInstead reason ev eq_rel swapped lhs rhs
|
| ... |
... |
@@ -2343,6 +2338,16 @@ do_not_prevent_rewriting = cteProblem cteSkolemEscape S.<> |
|
2343
|
2338
|
cteProblem cteConcrete
|
|
2344
|
2339
|
|
|
2345
|
2340
|
----------------------
|
|
|
2341
|
+finishWith :: CtEvidence -> EqRel -> SwapFlag
|
|
|
2342
|
+ -> CanEqLHS -> TcType
|
|
|
2343
|
+ -> TcS (StopOrContinue (Either unused EqCt))
|
|
|
2344
|
+finishWith ev eq_rel swapped can_lhs rhs_ty
|
|
|
2345
|
+ = do { new_ev <- rewriteEqEvidenceSwapOnly ev eq_rel swapped can_lhs rhs_ty
|
|
|
2346
|
+ ; continueWith $ Right $
|
|
|
2347
|
+ EqCt { eq_ev = new_ev, eq_eq_rel = eq_rel
|
|
|
2348
|
+ , eq_lhs = can_lhs , eq_rhs = rhs_ty } }
|
|
|
2349
|
+
|
|
|
2350
|
+{-
|
|
2346
|
2351
|
swapAndFinish :: CtEvidence -> EqRel -> SwapFlag
|
|
2347
|
2352
|
-> TcType -> CanEqLHS -- ty ~ F tys
|
|
2348
|
2353
|
-> TcS (StopOrContinue (Either unused EqCt))
|
| ... |
... |
@@ -2354,6 +2359,7 @@ swapAndFinish ev eq_rel swapped lhs_ty can_rhs |
|
2354
|
2359
|
; continueWith $ Right $
|
|
2355
|
2360
|
EqCt { eq_ev = new_ev, eq_eq_rel = eq_rel
|
|
2356
|
2361
|
, eq_lhs = can_rhs, eq_rhs = lhs_ty } }
|
|
|
2362
|
+-}
|
|
2357
|
2363
|
|
|
2358
|
2364
|
----------------------
|
|
2359
|
2365
|
tryIrredInstead :: CheckTyEqResult -> CtEvidence
|