From 2720c6609b7b7f6002dd0ffcc31ed0363f1208d9 Mon Sep 17 00:00:00 2001 From: simonpj Date: Tue, 28 Oct 2003 13:16:01 +0000 Subject: [PATCH] [project @ 2003-10-28 13:15:58 by simonpj] Wibbles about argument variance --- ghc/compiler/parser/RdrHsSyn.lhs | 2 ++ ghc/compiler/typecheck/TcTyDecls.lhs | 25 ++----------------------- ghc/compiler/types/TyCon.lhs | 6 +++--- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/ghc/compiler/parser/RdrHsSyn.lhs b/ghc/compiler/parser/RdrHsSyn.lhs index feee920..7d51a54 100644 --- a/ghc/compiler/parser/RdrHsSyn.lhs +++ b/ghc/compiler/parser/RdrHsSyn.lhs @@ -360,6 +360,8 @@ hsIfaceDecl (TyClD decl@(TyData {})) ifCtxt = hsIfaceCtxt (tcdCtxt decl), ifCons = Unknown, ifRec = NonRecursive, ifVrcs = [], ifGeneric = False } + -- I'm not sure that [] is right for ifVrcs, but + -- since we don't use them I'm not going to fiddle hsIfaceDecl (TyClD decl@(ClassDecl {})) = IfaceClass { ifName = rdrNameOcc (tcdName decl), diff --git a/ghc/compiler/typecheck/TcTyDecls.lhs b/ghc/compiler/typecheck/TcTyDecls.lhs index e67cabe..46a7892 100644 --- a/ghc/compiler/typecheck/TcTyDecls.lhs +++ b/ghc/compiler/typecheck/TcTyDecls.lhs @@ -333,11 +333,7 @@ calcTyConArgVrcs tyclss initial_oi :: NameEnv (TyCon, ArgVrcs) initial_oi = mkNameEnv [(tyConName tc, (tc, initial tc)) | tc <- tycons] - initial tc = if isAlgTyCon tc && isNothing (tyConDataCons_maybe tc) then - -- make pessimistic assumption (and warn) - abstractVrcs tc - else - replicate (tyConArity tc) (False,False) + initial tc = replicate (tyConArity tc) (False,False) tcaoFix :: NameEnv (TyCon, ArgVrcs) -- initial ArgVrcs per tycon -> NameEnv (TyCon, ArgVrcs) -- fixpointed ArgVrcs per tycon @@ -358,10 +354,7 @@ calcTyConArgVrcs tyclss -> ArgVrcs -- new ArgVrcs for tycon tcaoIter oi tc | isAlgTyCon tc - = if null data_cons then - abstractVrcs tc -- Data types with no constructors - else - map (\v -> anyVrc (vrcInTy (lookup oi) v) argtys) vs + = map (\v -> anyVrc (vrcInTy (lookup oi) v) argtys) vs where data_cons = tyConDataCons tc vs = tyConTyVars tc @@ -376,20 +369,6 @@ calcTyConArgVrcs tyclss Just (_, pms) -> pms Nothing -> tyConArgVrcs tc -- We use the already-computed result for tycons not in this SCC - - -abstractVrcs :: TyCon -> ArgVrcs -abstractVrcs tc = -#ifdef DEBUG - pprTrace "Vrc: abstract tycon:" (ppr tc) $ -#endif - warn_abstract_vrcs `seq` replicate (tyConArity tc) (True,True) - -warn_abstract_vrcs --- we pull the message out as a CAF so the warning only appears *once* - = trace ("WARNING: tyConArgVrc info inaccurate due to unavailable constructors.\n" - ++ " Use -fno-prune-tydecls to fix.") $ - () \end{code} diff --git a/ghc/compiler/types/TyCon.lhs b/ghc/compiler/types/TyCon.lhs index 9b40a44..dc81d81 100644 --- a/ghc/compiler/types/TyCon.lhs +++ b/ghc/compiler/types/TyCon.lhs @@ -195,8 +195,8 @@ data DataConDetails datacon = DataCons [datacon] -- Its data constructors, with fully polymorphic types -- A type can have zero constructors - | Unknown -- We're importing this data type from an hi-boot file - -- and we don't know what its constructors are + | Unknown -- Used only when We're importing this data type from an + -- hi-boot file, so we don't know what its constructors are visibleDataCons (DataCons cs) = cs visibleDataCons other = [] @@ -452,7 +452,7 @@ tyConHasGenerics other = False -- Synonyms tyConDataConDetails :: TyCon -> DataConDetails DataCon tyConDataConDetails (AlgTyCon {dataCons = cons}) = cons tyConDataConDetails (TupleTyCon {dataCon = con}) = DataCons [con] -tyConDataConDetails other = Unknown +tyConDataConDetails other = pprPanic "tyConDataConDetails" (ppr other) tyConDataCons :: TyCon -> [DataCon] -- It's convenient for tyConDataCons to return the -- 1.7.10.4