Skip to content
Snippets Groups Projects
Commit 06facab6 authored by Joachim Breitner's avatar Joachim Breitner
Browse files

Refactor deferTcSForAllEq: Do not bind, but return EvTerm

parent 1791ea0a
No related merge requests found
......@@ -245,7 +245,8 @@ canClass ev cls tys
, CtWanted { ctev_loc = loc, ctev_evar = orig_ev } <- ev
, equalLength tvs1 tvs2
= do { traceTcS "Creating implication for polytype coercible equality" $ ppr ev
; deferTcSForAllEq Representational (loc,orig_ev) (tvs1,body1) (tvs2,body2)
; ev_term <- deferTcSForAllEq Representational loc (tvs1,body1) (tvs2,body2)
; setEvBind orig_ev ev_term
; return Stop }
canClass ev cls tys
......@@ -766,7 +767,8 @@ canEqNC ev s1@(ForAllTy {}) s2@(ForAllTy {})
canEqFailure ev s1 s2
else
do { traceTcS "Creating implication for polytype equality" $ ppr ev
; deferTcSForAllEq Nominal (loc,orig_ev) (tvs1,body1) (tvs2,body2)
; ev_term <- deferTcSForAllEq Nominal loc (tvs1,body1) (tvs2,body2)
; setEvBind orig_ev ev_term
; return Stop } }
| otherwise
= do { traceTcS "Ommitting decomposition of given polytype equality" $
......
......@@ -1751,13 +1751,13 @@ matchFam tycon args
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
deferTcSForAllEq :: Role -- Nominal or Representational
-> (CtLoc,EvVar) -- Original wanted equality flavor
-> CtLoc -- Original wanted equality flavor
-> ([TyVar],TcType) -- ForAll tvs1 body1
-> ([TyVar],TcType) -- ForAll tvs2 body2
-> TcS ()
-> TcS EvTerm
-- Some of this functionality is repeated from TcUnify,
-- consider having a single place where we create fresh implications.
deferTcSForAllEq role (loc,orig_ev) (tvs1,body1) (tvs2,body2)
deferTcSForAllEq role loc (tvs1,body1) (tvs2,body2)
= do { (subst1, skol_tvs) <- wrapTcS $ TcM.tcInstSkolTyVars tvs1
; let tys = mkTyVarTys skol_tvs
phi1 = Type.substTy subst1 body1
......@@ -1790,8 +1790,7 @@ deferTcSForAllEq role (loc,orig_ev) (tvs1,body1) (tvs2,body2)
; updTcSImplics (consBag imp)
; return (TcLetCo ev_binds new_co) }
; setEvBind orig_ev $
EvCoercion (foldr mkTcForAllCo coe_inside skol_tvs)
; return $ EvCoercion (foldr mkTcForAllCo coe_inside skol_tvs)
}
\end{code}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment