import Inst ( InstOrigin(..), LIE, emptyLIE, plusLIE, plusLIEs, newDicts, newMethod )
import TcEnv ( TcId, ValueEnv, TyThing(..), TyThingDetails(..), tcAddImportedIdInfo,
- tcLookupTy, tcExtendTyVarEnvForMeths, tcExtendGlobalTyVars,
+ tcLookupClass, tcExtendTyVarEnvForMeths, tcExtendGlobalTyVars,
tcExtendLocalValEnv, tcExtendTyVarEnv, newDefaultMethodName
)
import TcBinds ( tcBindWithSigs, tcSpecSigs )
%************************************************************************
\begin{code}
-tcClassDecl1 :: ValueEnv -> RenamedTyClDecl -> TcM s (Name, TyThingDetails)
+tcClassDecl1 :: ValueEnv -> RenamedTyClDecl -> TcM (Name, TyThingDetails)
tcClassDecl1 rec_env
(ClassDecl context class_name
tyvar_names fundeps class_sigs def_methods pragmas
(classArityErr class_name) `thenTc_`
-- LOOK THINGS UP IN THE ENVIRONMENT
- tcLookupTy class_name `thenTc` \ (AClass clas) ->
+ tcLookupClass class_name `thenTc` \ clas ->
let
tyvars = classTyVars clas
op_sigs = filter isClassOpSig class_sigs
\end{code}
\begin{code}
-checkDefaultBinds :: Class -> [Name] -> RenamedMonoBinds -> TcM s (NameEnv (DefMeth Name))
+checkDefaultBinds :: Class -> [Name] -> RenamedMonoBinds -> TcM (NameEnv (DefMeth Name))
-- Check default bindings
-- a) must be for a class op for this class
-- b) must be all generic or all non-generic
tcSuperClasses :: Class
-> RenamedContext -- class context
-> [Name] -- Names for superclass selectors
- -> TcM s (ClassContext, -- the superclass context
+ -> TcM (ClassContext, -- the superclass context
[Id]) -- superclass selector Ids
tcSuperClasses clas context sc_sel_names
-> [TyVar] -- The class type variable, used for error check only
-> NameEnv (DefMeth Name) -- Info about default methods
-> RenamedClassOpSig
- -> TcM s (Type, -- Type of the method
+ -> TcM (Type, -- Type of the method
ClassOpItem) -- Selector Id, default-method Id, True if explicit default binding
-- This warrants an explanation: we need to separate generic
and superclass dictionary.
\begin{code}
-mkImplicitClassBinds :: [Class] -> NF_TcM s ([Id], TcMonoBinds)
+mkImplicitClassBinds :: [Class] -> NF_TcM ([Id], TcMonoBinds)
mkImplicitClassBinds classes
= returnNF_Tc (concat cls_ids_s, andMonoBindList binds_s)
-- The selector binds are already in the selector Id's unfoldings
each local class decl.
\begin{code}
-tcClassDecls2 :: [RenamedHsDecl] -> NF_TcM s (LIE, TcMonoBinds)
+tcClassDecls2 :: [RenamedHsDecl] -> NF_TcM (LIE, TcMonoBinds)
tcClassDecls2 decls
= foldr combine
\begin{code}
tcClassDecl2 :: RenamedTyClDecl -- The class declaration
- -> NF_TcM s (LIE, TcMonoBinds)
+ -> NF_TcM (LIE, TcMonoBinds)
tcClassDecl2 (ClassDecl context class_name
tyvar_names _ sigs default_binds pragmas _ src_loc)
= -- A locally defined class
recoverNF_Tc (returnNF_Tc (emptyLIE, EmptyMonoBinds)) $
tcAddSrcLoc src_loc $
- tcLookupTy class_name `thenNF_Tc` \ (AClass clas) ->
+ tcLookupClass class_name `thenNF_Tc` \ clas ->
-- We make a separate binding for each default method.
-- At one time I used a single AbsBinds for all of them, thus
-> [RenamedSig] -- Pramgas (just for this one)
-> Bool -- True <=> This method is from an instance declaration
-> ClassOpItem -- The method selector and default-method Id
- -> TcM s (TcMonoBinds, LIE, (LIE, TcId))
+ -> TcM (TcMonoBinds, LIE, (LIE, TcId))
tcMethodBind clas origin inst_tyvars inst_tys inst_theta
meth_binds prags is_inst_decl (sel_id, dm_info)
-- have not been unified with anything in the environment
--
-- We do this for each method independently to localise error messages
+ -- ...and this is why the call to tcExtendGlobalTyVars must be here
+ -- rather than in the caller
tcAddErrCtxtM (sigCtxt sig_msg inst_tyvars inst_theta (idType meth_id)) $
checkSigTyVars inst_tyvars emptyVarSet `thenTc_`