X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcTyClsDecls.lhs;h=5a2f77375e2900b68af40dfd9eb128f01a16f4a8;hb=ba16e1bfde86cc6d8fafa9be8a33b3b6172f262f;hp=fa10fbf203c73c28bdcb2b2242c0390298e265e2;hpb=911dcb3217fa7b487d7253313ac5e238e72e2c58;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcTyClsDecls.lhs b/compiler/typecheck/TcTyClsDecls.lhs index fa10fbf..5a2f773 100644 --- a/compiler/typecheck/TcTyClsDecls.lhs +++ b/compiler/typecheck/TcTyClsDecls.lhs @@ -31,6 +31,7 @@ import Generics import Class import TyCon import DataCon +import Id import Var import VarSet import Name @@ -224,6 +225,10 @@ mkGlobalThings decls things = (name, AClass cl) mk_thing (L _ decl, ~(ATyCon tc)) = (tcdName decl, ATyCon tc) +#if __GLASGOW_HASKELL__ < 605 +-- Old GHCs don't understand that ~... matches anything + mk_thing _ = panic "mkGlobalThings: Can't happen" +#endif \end{code} @@ -239,10 +244,9 @@ lot of kinding and type checking code with ordinary algebraic data types (and GADTs). \begin{code} -tcFamInstDecl :: LTyClDecl Name -> TcM (Maybe TyThing) -- Nothing if error +tcFamInstDecl :: LTyClDecl Name -> TcM TyThing tcFamInstDecl (L loc decl) = -- Prime error recovery, set source location - recoverM (return Nothing) $ setSrcSpan loc $ tcAddDeclCtxt decl $ do { -- type families require -XTypeFamilies and can't be in an @@ -256,8 +260,7 @@ tcFamInstDecl (L loc decl) ; tc <- tcFamInstDecl1 decl ; checkValidTyCon tc -- Remember to check validity; -- no recursion to worry about here - ; return (Just (ATyCon tc)) - } + ; return (ATyCon tc) } tcFamInstDecl1 :: TyClDecl Name -> TcM TyCon @@ -282,14 +285,13 @@ tcFamInstDecl1 (decl@TySynonym {tcdLName = L loc tc_name}) ; t_typats <- mapM tcHsKindedType k_typats ; t_rhs <- tcHsKindedType k_rhs - -- (3) check that - -- - check the well-formedness of the instance + -- (3) check the well-formedness of the instance ; checkValidTypeInst t_typats t_rhs -- (4) construct representation tycon ; rep_tc_name <- newFamInstTyConName tc_name loc ; buildSynTyCon rep_tc_name t_tvs (SynonymTyCon t_rhs) - (Just (family, t_typats)) + (typeKind t_rhs) (Just (family, t_typats)) }} -- "newtype instance" and "data instance" @@ -655,7 +657,8 @@ tcSynDecl = tcTyVarBndrs tvs $ \ tvs' -> do { traceTc (text "tcd1" <+> ppr tc_name) ; rhs_ty' <- tcHsKindedType rhs_ty - ; tycon <- buildSynTyCon tc_name tvs' (SynonymTyCon rhs_ty') Nothing + ; tycon <- buildSynTyCon tc_name tvs' (SynonymTyCon rhs_ty') + (typeKind rhs_ty') Nothing ; return (ATyCon tycon) } tcSynDecl d = pprPanic "tcSynDecl" (ppr d) @@ -681,7 +684,7 @@ tcTyClDecl1 _calc_isrec -- Check that we don't use families without -XTypeFamilies ; checkTc idx_tys $ badFamInstDecl tc_name - ; tycon <- buildSynTyCon tc_name tvs' (OpenSynTyCon kind Nothing) Nothing + ; tycon <- buildSynTyCon tc_name tvs' (OpenSynTyCon kind Nothing) kind Nothing ; return [ATyCon tycon] } @@ -1071,10 +1074,10 @@ checkValidDataCon tc con = setSrcSpan (srcLocSpan (getSrcLoc con)) $ addErrCtxt (dataConCtxt con) $ do { checkTc (dataConTyCon con == tc) (badDataConTyCon con) - ; checkValidType ctxt (dataConUserType con) ; checkValidMonoType (dataConOrigResTy con) -- Disallow MkT :: T (forall a. a->a) -- Reason: it's really the argument of an equality constraint + ; checkValidType ctxt (dataConUserType con) ; when (isNewTyCon tc) (checkNewDataCon con) } where