tcHsTypeKind, tcHsType, tcHsTopType, tcHsTopBoxedType,
tcContext, tcHsTopTypeKind
)
-import TcType ( zonkTcTyVarToTyVar, zonkTcThetaType )
+import TcType ( zonkTcTyVarToTyVar, zonkTcClassConstraints )
import TcEnv ( tcLookupTy, TcTyThing(..) )
import TcMonad
import TcUnify ( unifyKind )
)
import MkId ( mkDataConId, mkRecordSelId, mkNewTySelId )
import Id ( getIdUnfolding )
-import CoreUnfold ( getUnfoldingTemplate )
+import CoreUnfold ( unfoldingTemplate )
import FieldLabel
import Var ( Id, TyVar )
-import Name ( Name, isLocallyDefined, OccName, NamedThing(..) )
+import Name ( Name, isLocallyDefined, OccName, NamedThing(..), nameUnique )
import Outputable
import TyCon ( TyCon, ArgVrcs, mkSynTyCon, mkAlgTyCon, isAlgTyCon,
isSynTyCon, tyConDataCons, isNewTyCon
mkTyConApp, mkTyVarTys, mkForAllTys, mkFunTy,
mkTyVarTy,
mkArrowKind, mkArrowKinds, boxedTypeKind,
- isUnboxedType, Type, ThetaType
+ isUnboxedType, Type, ThetaType, classesOfPreds
)
import Var ( tyVarKind )
import VarSet ( intersectVarSet, isEmptyVarSet )
-- Typecheck the pieces
tcContext context `thenTc` \ ctxt ->
- mapTc (tcConDecl rec_tycon tyvars ctxt) con_decls `thenTc` \ data_cons ->
+ let ctxt' = classesOfPreds ctxt in
+ mapTc (tcConDecl rec_tycon tyvars ctxt') con_decls `thenTc` \ data_cons ->
tc_derivs derivings `thenTc` \ derived_classes ->
let
argvrcs = lookupWithDefaultFM rec_vrcs (pprPanic "tcTyDecl: argvrcs:" $ ppr tycon_name)
tycon_name
- tycon = mkAlgTyCon tycon_name tycon_kind tyvars ctxt argvrcs
+ tycon = mkAlgTyCon tycon_name tycon_kind tyvars ctxt' argvrcs
data_cons
derived_classes
Nothing -- Not a dictionary
%************************************************************************
\begin{code}
-tcConDecl :: TyCon -> [TyVar] -> ThetaType -> RenamedConDecl -> TcM s DataCon
+tcConDecl :: TyCon -> [TyVar] -> [(Class,[Type])] -> RenamedConDecl -> TcM s DataCon
tcConDecl tycon tyvars ctxt (ConDecl name ex_tvs ex_ctxt details src_loc)
= tcAddSrcLoc src_loc $
tcExtendTyVarScope ex_tvs $ \ ex_tyvars ->
tcContext ex_ctxt `thenTc` \ ex_theta ->
- tc_con_decl_help tycon tyvars ctxt name ex_tyvars ex_theta details
+ let ex_ctxt' = classesOfPreds ex_theta in
+ tc_con_decl_help tycon tyvars ctxt name ex_tyvars ex_ctxt' details
tc_con_decl_help tycon tyvars ctxt name ex_tyvars ex_theta details
= case details of
-- immutable type variables. (The top-level tyvars are
-- already fixed, by the preceding kind-inference pass.)
mapNF_Tc zonkTcTyVarToTyVar ex_tyvars `thenNF_Tc` \ ex_tyvars' ->
- zonkTcThetaType ex_theta `thenNF_Tc` \ ex_theta' ->
+ zonkTcClassConstraints ex_theta `thenNF_Tc` \ ex_theta' ->
let
data_con = mkDataCon name arg_stricts fields
tyvars (thinContext arg_tys ctxt)
-- For the locally-defined things
-- we need to turn the unfoldings inside the Ids into bindings,
binds | isLocallyDefined tycon
- = [ CoreMonoBind data_id (getUnfoldingTemplate (getIdUnfolding data_id))
+ = [ CoreMonoBind data_id (unfoldingTemplate (getIdUnfolding data_id))
| data_id <- data_ids, isLocallyDefined data_id
]
| otherwise