Comments and tracing only
addWanted :: Avails -> Inst -> TcExpr -> [Inst] -> NF_TcM Avails
addWanted avails wanted rhs_expr wanteds
-- Do *not* add superclasses as well. Here's an example of why not
addWanted :: Avails -> Inst -> TcExpr -> [Inst] -> NF_TcM Avails
addWanted avails wanted rhs_expr wanteds
-- Do *not* add superclasses as well. Here's an example of why not
--- class Eq a => Foo a b
+-- class Eq b => Foo a b
-- instance Eq a => Foo [a] a
-- If we are reducing
-- (Foo [t] t)
-- we'll first deduce that it holds (via the instance decl). We
-- must not then overwrite the Eq t constraint with a superclass selection!
-- instance Eq a => Foo [a] a
-- If we are reducing
-- (Foo [t] t)
-- we'll first deduce that it holds (via the instance decl). We
-- must not then overwrite the Eq t constraint with a superclass selection!
--- ToDo: this isn't entirely unsatisfactory, because
+-- ToDo: this isn't entirely satisfactory, because
-- we may also lose some entirely-legitimate sharing this way
= ASSERT( not (wanted `elemFM` avails) )
-- we may also lose some entirely-legitimate sharing this way
= ASSERT( not (wanted `elemFM` avails) )
newDicts SignatureOrigin theta `thenNF_Tc` \ dicts ->
tcSimplifyCheck sig_msg forall_tvs dicts lie `thenTc` \ (free_lie, inst_binds) ->
newDicts SignatureOrigin theta `thenNF_Tc` \ dicts ->
tcSimplifyCheck sig_msg forall_tvs dicts lie `thenTc` \ (free_lie, inst_binds) ->
+
+#ifdef DEBUG
+ zonkTcTyVars forall_tvs `thenNF_Tc` \ forall_tys ->
+ traceTc (text "tcGen" <+> vcat [text "extra_tvs" <+> ppr extra_tvs,
+ text "expected_ty" <+> ppr expected_ty,
+ text "inst ty" <+> ppr forall_tvs <+> ppr theta <+> ppr phi_ty,
+ text "free_tvs" <+> ppr free_tvs,
+ text "forall_tys" <+> ppr forall_tys]) `thenNF_Tc_`
+#endif
+
checkSigTyVarsWrt free_tvs forall_tvs `thenTc` \ zonked_tvs ->
checkSigTyVarsWrt free_tvs forall_tvs `thenTc` \ zonked_tvs ->
+ traceTc (text "tcGen:done") `thenNF_Tc_`
+
let
-- This HsLet binds any Insts which came out of the simplification.
-- It's a bit out of place here, but using AbsBind involves inventing
let
-- This HsLet binds any Insts which came out of the simplification.
-- It's a bit out of place here, but using AbsBind involves inventing
let
env_tvs = gbl_tvs `unionVarSet` extra_tvs
in
let
env_tvs = gbl_tvs `unionVarSet` extra_tvs
in
+ traceTc (text "check_sig_tyvars" <+> (vcat [text "sig_tys" <+> ppr sig_tys,
+ text "gbl_tvs" <+> ppr gbl_tvs,
+ text "extra_tvs" <+> ppr extra_tvs])) `thenNF_Tc_`
+
checkTcM (allDistinctTyVars sig_tys env_tvs)
(complain sig_tys env_tvs) `thenTc_`
checkTcM (allDistinctTyVars sig_tys env_tvs)
(complain sig_tys env_tvs) `thenTc_`