isWantedCo, fromWantedCo, fromGivenCo, eqInstCoType,
mkIdEqInstCo, mkSymEqInstCo, mkLeftTransEqInstCo,
mkRightTransEqInstCo, mkAppEqInstCo,
- eitherEqInst, mkEqInst, mkEqInsts, mkWantedEqInst, finalizeEqInst,
+ isValidWantedEqInst,
+ eitherEqInst, mkEqInst, mkEqInsts, mkWantedEqInst,
+ wantedToLocalEqInst, finalizeEqInst,
eqInstType, updateEqInstCoercion,
eqInstCoercion, eqInstTys
) where
Operations on entire EqInst.
\begin{code}
+-- For debugging, make sure the cotv of a wanted is not filled.
+--
+isValidWantedEqInst :: Inst -> TcM Bool
+isValidWantedEqInst (EqInst {tci_co = Left cotv})
+ = liftM not $ isFilledMetaTyVar cotv
+isValidWantedEqInst _ = return True
+
eitherEqInst :: Inst -- given or wanted EqInst
-> (TcTyVar -> a) -- result if wanted
-> (Coercion -> a) -- result if given
}
mkWantedEqInst pred = pprPanic "mkWantedEqInst" (ppr pred)
+-- Turn a wanted equality into a local that propagates the uninstantiated
+-- coercion variable as witness. We need this to propagate wanted irreds into
+-- attempts to solve implication constraints.
+--
+wantedToLocalEqInst :: Inst -> Inst
+wantedToLocalEqInst eq@(EqInst {tci_co = Left cotv})
+ = eq {tci_co = Right (mkTyVarTy cotv)}
+wantedToLocalEqInst eq = eq
+
-- Turn a wanted into a local EqInst (needed during type inference for
-- signatures)
--