X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcHsType.lhs;h=fc7a8486f9a35df58d16a48e2cd2e2686758e262;hb=b99310f05faee2abec850da4349fcd5c0498f7ca;hp=4d3224c596d1643ff60f2cf5031a01944aeb92bb;hpb=654a1ba16e47d3ddabeb74b809ee6097c0770d35;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcHsType.lhs b/compiler/typecheck/TcHsType.lhs index 4d3224c..fc7a848 100644 --- a/compiler/typecheck/TcHsType.lhs +++ b/compiler/typecheck/TcHsType.lhs @@ -6,7 +6,8 @@ \begin{code} module TcHsType ( - tcHsSigType, tcHsDeriv, + tcHsSigType, tcHsDeriv, + tcHsInstHead, tcHsQuantifiedType, UserTypeCtxt(..), -- Kind checking @@ -143,6 +144,24 @@ tcHsSigType ctxt hs_ty ; checkValidType ctxt ty ; returnM ty } +tcHsInstHead :: LHsType Name -> TcM ([TyVar], ThetaType, Type) +-- Typecheck an instance head. We can't use +-- tcHsSigType, because it's not a valid user type. +tcHsInstHead hs_ty + = do { kinded_ty <- kcHsSigType hs_ty + ; poly_ty <- tcHsKindedType kinded_ty + ; return (tcSplitSigmaTy poly_ty) } + +tcHsQuantifiedType :: [LHsTyVarBndr Name] -> LHsType Name -> TcM ([TyVar], Type) +-- Behave very like type-checking (HsForAllTy sig_tvs hs_ty), +-- except that we want to keep the tvs separate +tcHsQuantifiedType tv_names hs_ty + = kcHsTyVars tv_names $ \ tv_names' -> + do { kc_ty <- kcHsSigType hs_ty + ; tcTyVarBndrs tv_names' $ \ tvs -> + do { ty <- dsHsType kc_ty + ; return (tvs, ty) } } + -- Used for the deriving(...) items tcHsDeriv :: LHsType Name -> TcM ([TyVar], Class, [Type]) tcHsDeriv = addLocM (tc_hs_deriv []) @@ -506,6 +525,9 @@ ds_type full_ty@(HsForAllTy exp tv_names ctxt ty) ds_type (HsSpliceTy {}) = panic "ds_type: HsSpliceTy" +ds_type (HsDocTy ty _) -- Remove the doc comment + = dsHsType ty + dsHsTypes arg_tys = mappM dsHsType arg_tys \end{code} @@ -626,7 +648,7 @@ tcTyVarBndrs bndrs thing_inside where zonk (KindedTyVar name kind) = do { kind' <- zonkTcKindToKind kind ; return (mkTyVar name kind') } - zonk (UserTyVar name) = pprTrace "Un-kinded tyvar" (ppr name) $ + zonk (UserTyVar name) = WARN( True, ptext SLIT("Un-kinded tyvar") <+> ppr name ) return (mkTyVar name liftedTypeKind) ----------------------------------- @@ -641,9 +663,8 @@ tcDataKindSig (Just kind) = do { checkTc (isLiftedTypeKind res_kind) (badKindSig kind) ; span <- getSrcSpanM ; us <- newUniqueSupply - ; let loc = srcSpanStart span - uniqs = uniqsFromSupply us - ; return [ mk_tv loc uniq str kind + ; let uniqs = uniqsFromSupply us + ; return [ mk_tv span uniq str kind | ((kind, str), uniq) <- arg_kinds `zip` names `zip` uniqs ] } where (arg_kinds, res_kind) = splitKindFunTys kind @@ -722,16 +743,10 @@ tcHsPatSigType ctxt hs_ty | n <- nameSetToList (extractHsTyVars hs_ty), not (in_scope n) ] - -- Behave very like type-checking (HsForAllTy sig_tvs hs_ty), - -- except that we want to keep the tvs separate - ; (kinded_tvs, kinded_ty) <- kcHsTyVars sig_tvs $ \ kinded_tvs -> do - { kinded_ty <- kcTypeType hs_ty - ; return (kinded_tvs, kinded_ty) } - ; tcTyVarBndrs kinded_tvs $ \ tyvars -> do - { sig_ty <- dsHsType kinded_ty + ; (tyvars, sig_ty) <- tcHsQuantifiedType sig_tvs hs_ty ; checkValidType ctxt sig_ty ; return (tyvars, sig_ty) - } } + } tcPatSig :: UserTypeCtxt -> LHsType Name