import CmdLineOpts ( DynFlags, DynFlag(..), dopt )
import HsSyn ( TyClDecl(..),
ConDecl(..), Sig(..), HsPred(..),
- tyClDeclName, hsTyVarNames,
+ tyClDeclName, hsTyVarNames, tyClDeclTyVars,
isIfaceSigDecl, isClassDecl, isSynDecl, isClassOpSig
)
import RnHsSyn ( RenamedTyClDecl, tyClDeclFVs )
import TcUnify ( unifyKind )
import TcInstDcls ( tcAddDeclCtxt )
-import Type ( Kind, mkArrowKind, zipFunTys )
+import Type ( Kind, mkArrowKind, liftedTypeKind, zipFunTys )
import Variance ( calcTyConArgVrcs )
import Class ( Class, mkClass, classTyCon )
import TyCon ( TyCon, tyConKind, ArgVrcs, AlgTyConFlavour(..),
- mkSynTyCon, mkAlgTyCon, mkClassTyCon )
+ mkSynTyCon, mkAlgTyCon, mkClassTyCon, mkForeignTyCon )
import DataCon ( isNullaryDataCon )
import Var ( varName )
import FiniteMap
zonkKindEnv initial_kinds `thenNF_Tc` \ final_kinds ->
-- Tie the knot
+ traceTc (text "starting" <+> ppr final_kinds) `thenTc_`
fixTc ( \ ~(rec_details_list, _, _) ->
-- Step 4
let
tcSetEnv env $
+ traceTc (text "ready for pass 2" <+> ppr (isRec is_rec)) `thenTc_`
+
-- Step 6
-- For a recursive group, check all the types again,
-- this time with the wimp flag off
returnTc ()
) `thenTc_`
+ traceTc (text "done") `thenTc_`
+
-- Step 7
-- Extend the environment with the final TyCons/Classes
-- and their implicit Ids
\begin{code}
getInitialKind :: RenamedTyClDecl -> NF_TcM (Name, TcKind)
getInitialKind decl
- = kcHsTyVars (tcdTyVars decl) `thenNF_Tc` \ arg_kinds ->
- newKindVar `thenNF_Tc` \ result_kind ->
+ = kcHsTyVars (tyClDeclTyVars decl) `thenNF_Tc` \ arg_kinds ->
+ newKindVar `thenNF_Tc` \ result_kind ->
returnNF_Tc (tcdName decl, mk_kind arg_kinds result_kind)
mk_kind tvs_w_kinds res_kind = foldr (mkArrowKind . snd) res_kind tvs_w_kinds
kcHsType rhs `thenTc` \ rhs_kind ->
unifyKind result_kind rhs_kind
+kcTyClDecl (ForeignType {}) = returnTc ()
+
kcTyClDecl decl@(TyData {tcdND = new_or_data, tcdCtxt = context, tcdCons = con_decls})
= kcTyClDeclBody decl $ \ result_kind ->
kcHsContext context `thenTc_`
AThing kind -> kind
-- For some odd reason, a class doesn't include its kind
- (tyvars_w_kinds, result_kind) = zipFunTys (hsTyVarNames (tcdTyVars decl)) kind
+ (tyvars_w_kinds, result_kind) = zipFunTys (hsTyVarNames (tyClDeclTyVars decl)) kind
in
tcExtendKindEnv tyvars_w_kinds (thing_inside result_kind)
\end{code}
| otherwise -> DataTyCon
buildTyConOrClass dflags is_rec kenv rec_vrcs rec_details
+ (ForeignType {tcdName = tycon_name})
+ = ATyCon (mkForeignTyCon tycon_name liftedTypeKind 0 [])
+
+buildTyConOrClass dflags is_rec kenv rec_vrcs rec_details
(ClassDecl {tcdName = class_name, tcdTyVars = tyvar_names,
tcdFDs = fundeps, tcdSysNames = name_list} )
= AClass clas
mkClassEdges :: RenamedTyClDecl -> Maybe (RenamedTyClDecl, Name, [Name])
-mkClassEdges decl@(ClassDecl {tcdCtxt = ctxt, tcdName = name}) = Just (decl, name, [c | HsPClass c _ <- ctxt])
+mkClassEdges decl@(ClassDecl {tcdCtxt = ctxt, tcdName = name}) = Just (decl, name, [c | HsClassP c _ <- ctxt])
mkClassEdges other_decl = Nothing
mkEdges :: RenamedTyClDecl -> (RenamedTyClDecl, Name, [Name])