Commit ee1a35ad authored by Simon Peyton Jones's avatar Simon Peyton Jones

Tidy up the canonicaliser

I have forgotten what the original driver for this change was.
There is quite a bit of refactoring in TcCanonical; the rest
is minor.
parent a2fe5d21
This diff is collapsed.
......@@ -468,6 +468,7 @@ data EvTerm
| EvSuperClass DictId Int -- n'th superclass. Used for both equalities and
-- dictionaries, even though the former have no
-- selector Id. We count up from _0_
| EvKindCast EvVar TcCoercion -- See Note [EvKindCast]
deriving( Data.Data, Data.Typeable)
......@@ -475,7 +476,6 @@ data EvTerm
Note [EvKindCast]
~~~~~~~~~~~~~~~~~
EvKindCast g kco is produced when we have a constraint (g : s1 ~ s2)
but the kinds of s1 and s2 (k1 and k2 respectively) don't match but
are rather equal by a coercion. You may think that this coercion will
......@@ -485,8 +485,7 @@ that coercion will be an 'error' term, which we want to evaluate rather
than silently forget about!
The relevant (and only) place where such a coercion is produced in
the simplifier is in emit_kind_constraint in TcCanonical.
the simplifier is in TcCanonical.emitKindConstraint.
Note [EvBinds/EvTerm]
~~~~~~~~~~~~~~~~~~~~~
......
......@@ -1219,6 +1219,10 @@ data EvVarCreated
= EvVarCreated { evc_is_new :: Bool -- True iff the variable was just created
, evc_the_evvar :: EvVar } -- The actual evidence variable could be cached or new
instance Outputable EvVarCreated where
ppr (EvVarCreated { evc_is_new = is_new, evc_the_evvar = ev })
= ppr ev <> parens (if is_new then ptext (sLit "new") else ptext (sLit "old"))
isNewEvVar :: EvVarCreated -> Bool
isNewEvVar = evc_is_new
......@@ -1347,9 +1351,10 @@ newGivenEqVar fl ty1 ty2 co
newEqVar :: CtFlavor -> TcType -> TcType -> TcS EvVarCreated
newEqVar fl ty1 ty2
= newEvVar fl (mkEqPred (ty1,ty2))
= do { let pred = mkEqPred (ty1,ty2)
; v <- newEvVar fl pred
; traceTcS "newEqVar" (ppr v <+> dcolon <+> ppr pred)
; return v }
\end{code}
......@@ -1418,6 +1423,4 @@ getCtCoercion ct
-- solved, so it is not safe to simply do a mkTcCoVarCo (cc_id ct)
-- Instead we use the most accurate type, given by ctPred c
where maybe_given = isGiven_maybe (cc_flavor ct)
\end{code}
\ No newline at end of file
......@@ -240,7 +240,7 @@ simplifyInfer _top_lvl apply_mr name_taus wanteds
| isEmptyWC wanteds
= do { gbl_tvs <- tcGetGlobalTyVars -- Already zonked
; zonked_taus <- zonkTcTypes (map snd name_taus)
; let tvs_to_quantify = tyVarsOfTypes zonked_taus `minusVarSet` gbl_tvs
; let tvs_to_quantify = varSetElems (tyVarsOfTypes zonked_taus `minusVarSet` gbl_tvs)
-- tvs_to_quantify can contain both kind and type vars
-- See Note [Which variables to quantify]
; qtvs <- zonkQuantifiedTyVars tvs_to_quantify
......@@ -333,7 +333,7 @@ simplifyInfer _top_lvl apply_mr name_taus wanteds
-- they are also bound in ic_skols and we want them to be
-- tidied uniformly
; qtvs_to_return <- zonkQuantifiedTyVars qtvs
; qtvs_to_return <- zonkQuantifiedTyVars (varSetElems qtvs)
-- Step 5
-- Minimize `bound' and emit an implication
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment