import TyVar ( GenTyVar, mkTyVarSet )
import TysWiredIn ( stringTy )
import Unique ( Unique )
-import Util ( panic )
+import Util ( zipEqual, panic )
\end{code}
Typechecking instance declarations is done in two passes. The first
else
-- Make the dfun id and constant-method ids
- mkInstanceRelatedIds from_here inst_mod pragmas
+ mkInstanceRelatedIds from_here src_loc inst_mod pragmas
clas inst_tyvars inst_tau inst_theta uprags
`thenTc` \ (dfun_id, dfun_theta, const_meth_ids) ->
tcInstTheta tenv dfun_theta `thenNF_Tc` \ dfun_theta' ->
tcInstTheta tenv inst_decl_theta `thenNF_Tc` \ inst_decl_theta' ->
let
- sc_theta' = super_classes `zip` (repeat inst_ty')
+ sc_theta' = super_classes `zip` repeat inst_ty'
origin = InstanceDeclOrigin
mk_method sel_id = newMethodId sel_id inst_ty' origin locn
in
inst_tyvars'
dfun_arg_dicts_ids
((this_dict_id, RealId dfun_id)
- : (meth_ids `zip` (map RealId const_meth_ids)))
- -- const_meth_ids will often be empty
+ : (meth_ids `zip` map RealId const_meth_ids))
+ -- NB: const_meth_ids will often be empty
super_binds
(RecBind dict_and_method_binds)
let
tag = classOpTagByString clas occ
method_id = method_ids !! (tag-1)
+ in
- method_ty = tcIdType method_id
+ -- The "method" might be a RealId, when processInstBinds is used by
+ -- TcClassDcls:buildDefaultMethodBinds to make default-method bindings
+ (case method_id of
+ TcId id -> returnNF_Tc (idType id)
+ RealId id -> tcInstType [] (idType id)
+ ) `thenNF_Tc` \ method_ty ->
+ let
(method_tyvars, method_theta, method_tau) = splitSigmaTy method_ty
in
- newDicts origin method_theta `thenNF_Tc` \ (method_dicts,method_dict_ids) ->
+ newDicts origin method_theta `thenNF_Tc` \ (method_dicts,method_dict_ids) ->
case (method_tyvars, method_dict_ids) of
mk_spec_origin clas ty
= InstanceSpecOrigin inst_mapper clas ty src_loc
+ -- I'm VERY SUSPICIOUS ABOUT THIS
+ -- the inst-mapper is in a knot at this point so it's no good
+ -- looking at it in tcSimplify...
in
tcSimplifyThetas mk_spec_origin subst_tv_theta
`thenTc` \ simpl_tv_theta ->
let
simpl_theta = [ (clas, tv_to_tmpl tv) | (clas, tv) <- simpl_tv_theta ]
- tv_tmpl_map = inst_tv_tys `zipEqual` inst_tmpl_tys
+ tv_tmpl_map = zipEqual "tcSpecInstSig" inst_tv_tys inst_tmpl_tys
tv_to_tmpl tv = assoc "tcSpecInstSig" tv_tmpl_map tv
in
- mkInstanceRelatedIds e True{-from here-} mod NoInstancePragmas src_loc
+ mkInstanceRelatedIds e True{-from here-} src_loc mod NoInstancePragmas
clas inst_tmpls inst_ty simpl_theta uprag
`thenTc` \ (dfun_id, dfun_theta, const_meth_ids) ->