import {-# SOURCE #-} Subst( substTy, mkTyVarSubst )
import CmdLineOpts ( opt_DictsStrict )
-import Type ( Type, ThetaType, TauType, ClassContext,
+import Type ( Type, TauType, ClassContext,
mkForAllTys, mkFunTys, mkTyConApp,
mkTyVarTys, mkDictTys,
- splitTyConApp_maybe, classesToPreds
+ splitTyConApp_maybe
)
import TyCon ( TyCon, tyConDataCons, tyConDataConsIfAvailable, isDataTyCon, isProductTyCon,
isTupleTyCon, isUnboxedTupleTyCon, isRecursiveTyCon )
Module, moduleName
-- abstract, instance of Eq, Ord, Outputable
, ModuleName
- , isModuleInThisPackage, mkModuleInThisPackage
+ , isModuleInThisPackage, mkModuleInThisPackage,
+ , printModulePrefix
, moduleNameString -- :: ModuleName -> EncodedString
, moduleNameUserString -- :: ModuleName -> UserString
-- as the one being compiled
| AnotherPackage PackageName -- A module from a different package
+ | DunnoYet -- This is used when we don't yet know
+ -- Main case: we've come across Foo.x in an interface file
+ -- but we havn't yet opened Foo.hi. We need a Name for Foo.x
+ -- Later on (in RnEnv.newTopBinder) we'll update the cache
+ -- to have the right PackageInfo
+
type PackageName = FastString -- No encoding at all
preludePackage :: PackageName
instance Outputable PackageInfo where
-- Just used in debug prints of lex tokens and in debug modde
ppr ThisPackage = ptext SLIT("<THIS>")
+ ppr DunnoYet = ptext SLIT("<?>")
ppr (AnotherPackage p) = ptext p
\end{code}
-- file, but before we've opened Foo.hi.
-- (Until we've opened Foo.hi we don't know what the PackageInfo is.)
mkVanillaModule :: ModuleName -> Module
-mkVanillaModule name = mkModule name (panic "mkVanillaModule:unknown mod_kind field")
+mkVanillaModule name = Module name DunnoYet
mkPrelModule :: ModuleName -> Module
mkPrelModule name = mkModule name preludePackage
isModuleInThisPackage :: Module -> Bool
isModuleInThisPackage (Module nm ThisPackage) = True
isModuleInThisPackage _ = False
+
+printModulePrefix :: Module -> Bool
+ -- When printing, say M.x
+printModulePrefix (Module nm ThisPackage) = False
+printModulePrefix _ = True
\end{code}
+
%************************************************************************
%* *
\subsection{@ModuleEnv@s}
import OccName -- All of it
import Module ( Module, moduleName, mkVanillaModule,
- isModuleInThisPackage )
+ printModulePrefix, isModuleInThisPackage )
import RdrName ( RdrName, mkRdrQual, mkRdrUnqual, rdrNameOcc,
rdrNameModule )
import CmdLineOpts ( opt_Static, opt_PprStyle_NoPrags,
global m | codeStyle sty
= ppr (moduleName m) <> char '_' <> pprOccName occ
- | debugStyle sty || not (isModuleInThisPackage m)
+ | debugStyle sty || printModulePrefix m
= ppr (moduleName m) <> dot <> pprOccName occ
| otherwise
= pprOccName occ
import RdrHsSyn ( RdrNameHsDecl, RdrNameTyClDecl )
import RnHsSyn ( RenamedTyClDecl, RenamedRuleDecl, RenamedInstDecl )
-import CoreSyn ( CoreRule, IdCoreRule )
+import CoreSyn ( IdCoreRule )
import Type ( Type )
import FiniteMap ( FiniteMap, emptyFM, addToFM, lookupFM, foldFM )
whats_imported :: { WhatsImported OccName }
whats_imported : { NothingAtAll }
| '::' version { Everything $2 }
- | '::' version version name_version_pairs version { Specifically $2 (Just $3) $4 $5 }
+ | '::' version version version name_version_pairs { Specifically $2 (Just $3) $5 $4 }
name_version_pairs :: { [(OccName, Version)] }
name_version_pairs : { [] }
NamedThing(..),
elemNameEnv
)
-import Module ( Module, ModuleEnv,
+import Module ( Module, ModuleEnv, mkVanillaModule,
moduleName, isModuleInThisPackage,
ModuleName, WhereFrom(..),
emptyModuleEnv, lookupModuleEnvByName,
Just mi -> returnRn (mi_module mi, mi_exports mi) ;
-- loadInterface always puts something in the map
-- even if it's a fake
- Nothing -> pprPanic "getInterfaceExports" (ppr mod_name)
+ Nothing -> returnRn (mkVanillaModule mod_name, [])
+ -- pprPanic "getInterfaceExports" (ppr mod_name)
}
where
doc_str = sep [ppr mod_name, ptext SLIT("is directly imported")]
substEnv, setSubstEnv, emptySubst, isInScope,
bindSubstList, unBindSubstList, substInScope, uniqAway
)
-import Id ( Id, idUnfolding, zapLamIdInfo,
- idSpecialisation, setIdSpecialisation
- )
-import Var ( isTyVar, isId )
+import Id ( Id, idUnfolding, idSpecialisation, setIdSpecialisation )
+import Var ( isId )
import VarSet
import VarEnv
import Type ( mkTyVarTy )
import BasicTypes ( Arity )
import Unique ( Unique, Uniquable(..) )
import Outputable
-import Util
\end{code}
%************************************************************************
isDictTy, splitTyConApp_maybe, splitFunTy_maybe,
splitUsForAllTys, predRepTy
)
-import Var ( TyVar, tyVarKind,
- tyVarName, setTyVarName
- )
+import Var ( TyVar, tyVarKind )
import TyCon ( TyCon, isPrimTyCon, isTupleTyCon, isUnboxedTupleTyCon,
maybeTyConSingleCon, isEnumerationTyCon,
- tyConArity, tyConUnique
+ tyConArity
)
-import Class ( Class, className )
+import Class ( Class )
-- others:
import Maybes ( maybeToBool )
-import Name ( getOccString, NamedThing(..) )
+import Name ( getOccString )
import Outputable
import PprEnv
import Unique ( Uniquable(..) )
ppr_ty env ctxt_prec (PredTy p) = braces (ppr_pred env p)
-ppr_theta env [] = empty
-ppr_theta env theta = braces (hsep (punctuate comma (map (ppr_pred env) theta)))
-
ppr_pred env (Class clas tys) = ppr clas <+>
hsep (map (ppr_ty env tYCON_PREC) tys)
ppr_pred env (IParam n ty) = hsep [char '?' <> ppr n, text "::",
import Class ( Class, ClassContext )
import Var ( TyVar, Id )
-import BasicTypes ( Arity, NewOrData(..), RecFlag(..), Boxity(..),
+import BasicTypes ( Arity, RecFlag(..), Boxity(..),
isBoxed, EP(..) )
import Name ( Name, nameUnique, NamedThing(getName) )
import PrelNames ( Unique, Uniquable(..), anyBoxConKey )
import VarSet
import Name ( Name, mkGlobalName, mkKindOccFS, tcName )
-import OccName ( mkOccFS, tcName )
+import OccName ( tcName )
import TyCon ( TyCon, KindCon,
mkFunTyCon, mkKindCon, mkSuperKindCon,
)