Commit ef5b4b14 authored by simonmar's avatar simonmar

[project @ 2004-11-26 16:19:45 by simonmar]

Further integration with the new package story.  GHC now supports
pretty much everything in the package proposal.

  - GHC now works in terms of PackageIds (<pkg>-<version>) rather than
    just package names.  You can still specify package names without
    versions on the command line, as long as the name is unambiguous.

  - GHC understands hidden/exposed modules in a package, and will refuse
    to import a hidden module.  Also, the hidden/eposed status of packages
    is taken into account.

  - I had to remove the old package syntax from ghc-pkg, backwards
    compatibility isn't really practical.

  - All the package.conf.in files have been rewritten in the new syntax,
    and contain a complete list of modules in the package.  I've set all
    the versions to 1.0 for now - please check your package(s) and fix the
    version number & other info appropriately.

  - New options:

	-hide-package P    sets the expose flag on package P to False
	-ignore-package P  unregisters P for this compilation

	For comparison, -package P sets the expose flag on package P
        to True, and also causes P to be linked in eagerly.

        -package-name is no longer officially supported.  Unofficially, it's
	a synonym for -ignore-package, which has more or less the same effect
	as -package-name used to.

	Note that a package may be hidden and yet still be linked into
	the program, by virtue of being a dependency of some other package.
	To completely remove a package from the compiler's internal database,
        use -ignore-package.

	The compiler will complain if any two packages in the
        transitive closure of exposed packages contain the same
        module.

	You *must* use -ignore-package P when compiling modules for
        package P, if package P (or an older version of P) is already
        registered.  The compiler will helpfully complain if you don't.
	The fptools build system does this.

   - Note: the Cabal library won't work yet.  It still thinks GHC uses
     the old package config syntax.

Internal changes/cleanups:

   - The ModuleName type has gone away.  Modules are now just (a
     newtype of) FastStrings, and don't contain any package information.
     All the package-related knowledge is in DynFlags, which is passed
     down to where it is needed.

   - DynFlags manipulation has been cleaned up somewhat: there are no
     global variables holding DynFlags any more, instead the DynFlags
     are passed around properly.

   - There are a few less global variables in GHC.  Lots more are
     scheduled for removal.

   - -i is now a dynamic flag, as are all the package-related flags (but
     using them in {-# OPTIONS #-} is Officially Not Recommended).

   - make -j now appears to work under fptools/libraries/.  Probably
     wouldn't take much to get it working for a whole build.
parent 1f8b341a
...@@ -522,6 +522,7 @@ endif ...@@ -522,6 +522,7 @@ endif
# from mkDependHS. # from mkDependHS.
SRC_MKDEPENDHS_OPTS += \ SRC_MKDEPENDHS_OPTS += \
-optdep--exclude-module=Compat.RawSystem \ -optdep--exclude-module=Compat.RawSystem \
-optdep--exclude-module=Compat.Directory \
-optdep--exclude-module=Data.Version \ -optdep--exclude-module=Data.Version \
-optdep--exclude-module=Distribution.Package \ -optdep--exclude-module=Distribution.Package \
-optdep--exclude-module=Distribution.InstalledPackageInfo \ -optdep--exclude-module=Distribution.InstalledPackageInfo \
......
__interface Module 1 0 where __interface Module 1 0 where
__export Module ModuleName ; __export Module Module ;
1 data ModuleName ; 1 data Module ;
module Module where module Module where
data ModuleName data Module
% %
% (c) The GRASP/AQUA Project, Glasgow University, 1992-2002 % (c) The University of Glasgow, 2004
% %
ModuleName Module
~~~~~~~~~~ ~~~~~~~~~~
Simply the name of a module, represented as a Z-encoded FastString. Simply the name of a module, represented as a Z-encoded FastString.
These are Uniquable, hence we can build FiniteMaps with ModuleNames as These are Uniquable, hence we can build FiniteMaps with ModuleNames as
the keys. the keys.
Module
~~~~~~
A ModuleName with some additional information, namely whether the
module resides in the Home package or in a different package. We need
to know this for two reasons:
* generating cross-DLL calls is different from intra-DLL calls
(see below).
* we don't record version information in interface files for entities
in a different package.
The unique of a Module is identical to the unique of a ModuleName, so
it is safe to look up in a Module map using a ModuleName and vice
versa.
Notes on DLLs
~~~~~~~~~~~~~
When compiling module A, which imports module B, we need to
know whether B will be in the same DLL as A.
If it's in the same DLL, we refer to B_f_closure
If it isn't, we refer to _imp__B_f_closure
When compiling A, we record in B's Module value whether it's
in a different DLL, by setting the DLL flag.
\begin{code} \begin{code}
module Module module Module
( (
Module, -- Abstract, instance of Eq, Ord, Outputable Module, -- Abstract, instance of Eq, Ord, Outputable
, pprModule -- :: ModuleName -> SDoc
, ModLocation(..), , ModLocation(..),
, showModMsg , showModMsg
, ModuleName , moduleString -- :: ModuleName -> EncodedString
, pprModuleName -- :: ModuleName -> SDoc , moduleUserString -- :: ModuleName -> UserString
, printModulePrefix , moduleFS -- :: ModuleName -> EncodedFS
, moduleName -- :: Module -> ModuleName , mkModule -- :: UserString -> ModuleName
, moduleNameString -- :: ModuleName -> EncodedString , mkModuleFS -- :: UserFS -> ModuleName
, moduleNameUserString -- :: ModuleName -> UserString , mkSysModuleFS -- :: EncodedFS -> ModuleName
, moduleNameFS -- :: ModuleName -> EncodedFS
, moduleString -- :: Module -> EncodedString
, moduleUserString -- :: Module -> UserString
, mkModule
, mkBasePkgModule -- :: UserString -> Module
, mkHomeModule -- :: ModuleName -> Module
, isHomeModule -- :: Module -> Bool
, mkPackageModule -- :: ModuleName -> Module
, mkModuleName -- :: UserString -> ModuleName
, mkModuleNameFS -- :: UserFS -> ModuleName
, mkSysModuleNameFS -- :: EncodedFS -> ModuleName
, pprModule,
, ModuleEnv, , ModuleEnv,
, elemModuleEnv, extendModuleEnv, extendModuleEnvList, plusModuleEnv_C , elemModuleEnv, extendModuleEnv, extendModuleEnvList, plusModuleEnv_C
...@@ -74,7 +31,6 @@ module Module ...@@ -74,7 +31,6 @@ module Module
, lookupWithDefaultModuleEnv, mapModuleEnv, mkModuleEnv, emptyModuleEnv , lookupWithDefaultModuleEnv, mapModuleEnv, mkModuleEnv, emptyModuleEnv
, moduleEnvElts, unitModuleEnv, isEmptyModuleEnv, foldModuleEnv , moduleEnvElts, unitModuleEnv, isEmptyModuleEnv, foldModuleEnv
, extendModuleEnv_C , extendModuleEnv_C
, lookupModuleEnvByName, extendModuleEnvByName, unitModuleEnvByName
, ModuleSet, emptyModuleSet, mkModuleSet, moduleSetElts, extendModuleSet, elemModuleSet , ModuleSet, emptyModuleSet, mkModuleSet, moduleSetElts, extendModuleSet, elemModuleSet
...@@ -83,8 +39,6 @@ module Module ...@@ -83,8 +39,6 @@ module Module
#include "HsVersions.h" #include "HsVersions.h"
import OccName import OccName
import Outputable import Outputable
import Packages ( PackageName, basePackage )
import CmdLineOpts ( opt_InPackage )
import Unique ( Uniquable(..) ) import Unique ( Uniquable(..) )
import Maybes ( expectJust ) import Maybes ( expectJust )
import UniqFM import UniqFM
...@@ -93,44 +47,6 @@ import Binary ...@@ -93,44 +47,6 @@ import Binary
import FastString import FastString
\end{code} \end{code}
%************************************************************************
%* *
\subsection{Interface file flavour}
%* *
%************************************************************************
A further twist to the tale is the support for dynamically linked
libraries under Win32. Here, dealing with the use of global variables
that's residing in a DLL requires special handling at the point of use
(there's an extra level of indirection, i.e., (**v) to get at v's
value, rather than just (*v) .) When slurping in an interface file we
then record whether it's coming from a .hi corresponding to a module
that's packaged up in a DLL or not, so that we later can emit the
appropriate code.
The logic for how an interface file is marked as corresponding to a
module that's hiding in a DLL is explained elsewhere (ToDo: give
renamer href here.)
\begin{code}
data Module = Module ModuleName !PackageInfo
data PackageInfo
= ThisPackage -- A module from the same package
-- as the one being compiled
| AnotherPackage -- A module from a different package
packageInfoPackage :: PackageInfo -> PackageName
packageInfoPackage ThisPackage = opt_InPackage
packageInfoPackage AnotherPackage = FSLIT("<pkg>")
instance Outputable PackageInfo where
-- Just used in debug prints of lex tokens and in debug modde
ppr pkg_info = ppr (packageInfoPackage pkg_info)
\end{code}
%************************************************************************ %************************************************************************
%* * %* *
\subsection{Module locations} \subsection{Module locations}
...@@ -187,124 +103,54 @@ where the object file will reside if/when it is created. ...@@ -187,124 +103,54 @@ where the object file will reside if/when it is created.
%************************************************************************ %************************************************************************
\begin{code} \begin{code}
newtype ModuleName = ModuleName EncodedFS newtype Module = Module EncodedFS
-- Haskell module names can include the quote character ', -- Haskell module names can include the quote character ',
-- so the module names have the z-encoding applied to them -- so the module names have the z-encoding applied to them
instance Binary ModuleName where instance Binary Module where
put_ bh (ModuleName m) = put_ bh m put_ bh (Module m) = put_ bh m
get bh = do m <- get bh; return (ModuleName m) get bh = do m <- get bh; return (Module m)
instance Uniquable ModuleName where instance Uniquable Module where
getUnique (ModuleName nm) = getUnique nm getUnique (Module nm) = getUnique nm
instance Eq ModuleName where instance Eq Module where
nm1 == nm2 = getUnique nm1 == getUnique nm2 nm1 == nm2 = getUnique nm1 == getUnique nm2
-- Warning: gives an ordering relation based on the uniques of the -- Warning: gives an ordering relation based on the uniques of the
-- FastStrings which are the (encoded) module names. This is _not_ -- FastStrings which are the (encoded) module names. This is _not_
-- a lexicographical ordering. -- a lexicographical ordering.
instance Ord ModuleName where instance Ord Module where
nm1 `compare` nm2 = getUnique nm1 `compare` getUnique nm2 nm1 `compare` nm2 = getUnique nm1 `compare` getUnique nm2
instance Outputable ModuleName where
ppr = pprModuleName
pprModuleName :: ModuleName -> SDoc
pprModuleName (ModuleName nm) = pprEncodedFS nm
moduleNameFS :: ModuleName -> EncodedFS
moduleNameFS (ModuleName mod) = mod
moduleNameString :: ModuleName -> EncodedString
moduleNameString (ModuleName mod) = unpackFS mod
moduleNameUserString :: ModuleName -> UserString
moduleNameUserString (ModuleName mod) = decode (unpackFS mod)
-- used to be called mkSrcModule
mkModuleName :: UserString -> ModuleName
mkModuleName s = ModuleName (mkFastString (encode s))
-- used to be called mkSrcModuleFS
mkModuleNameFS :: UserFS -> ModuleName
mkModuleNameFS s = ModuleName (encodeFS s)
-- used to be called mkSysModuleFS
mkSysModuleNameFS :: EncodedFS -> ModuleName
mkSysModuleNameFS s = ModuleName s
\end{code}
\begin{code}
instance Outputable Module where instance Outputable Module where
ppr = pprModule ppr = pprModule
instance Uniquable Module where
getUnique (Module nm _) = getUnique nm
-- Same if they have the same name.
instance Eq Module where
m1 == m2 = getUnique m1 == getUnique m2
-- Warning: gives an ordering relation based on the uniques of the
-- FastStrings which are the (encoded) module names. This is _not_
-- a lexicographical ordering.
instance Ord Module where
m1 `compare` m2 = getUnique m1 `compare` getUnique m2
\end{code}
\begin{code}
pprModule :: Module -> SDoc pprModule :: Module -> SDoc
pprModule (Module mod p) = getPprStyle $ \ sty -> pprModule (Module nm) = pprEncodedFS nm
if debugStyle sty then
-- Print the package too
-- Don't use '.' because it gets confused
-- with module names
brackets (ppr p) <> pprModuleName mod
else
pprModuleName mod
\end{code}
\begin{code}
mkModule :: PackageName -> ModuleName -> Module
mkModule pkg_name mod_name
= Module mod_name pkg_info
where
pkg_info
| opt_InPackage == pkg_name = ThisPackage
| otherwise = AnotherPackage
mkBasePkgModule :: ModuleName -> Module
mkBasePkgModule mod_nm = mkModule basePackage mod_nm
mkHomeModule :: ModuleName -> Module
mkHomeModule mod_nm = Module mod_nm ThisPackage
isHomeModule :: Module -> Bool
isHomeModule (Module nm ThisPackage) = True
isHomeModule _ = False
mkPackageModule :: ModuleName -> Module moduleFS :: Module -> EncodedFS
mkPackageModule mod_nm = Module mod_nm AnotherPackage moduleFS (Module mod) = mod
moduleString :: Module -> EncodedString moduleString :: Module -> EncodedString
moduleString (Module (ModuleName fs) _) = unpackFS fs moduleString (Module mod) = unpackFS mod
moduleName :: Module -> ModuleName
moduleName (Module mod pkg_info) = mod
moduleUserString :: Module -> UserString moduleUserString :: Module -> UserString
moduleUserString (Module mod _) = moduleNameUserString mod moduleUserString (Module mod) = decode (unpackFS mod)
printModulePrefix :: Module -> Bool -- used to be called mkSrcModule
-- When printing, say M.x mkModule :: UserString -> Module
printModulePrefix (Module nm ThisPackage) = False mkModule s = Module (mkFastString (encode s))
printModulePrefix _ = True
\end{code}
-- used to be called mkSrcModuleFS
mkModuleFS :: UserFS -> Module
mkModuleFS s = Module (encodeFS s)
-- used to be called mkSysModuleFS
mkSysModuleFS :: EncodedFS -> Module
mkSysModuleFS s = Module s
\end{code}
%************************************************************************ %************************************************************************
%* * %* *
...@@ -314,9 +160,6 @@ printModulePrefix _ = True ...@@ -314,9 +160,6 @@ printModulePrefix _ = True
\begin{code} \begin{code}
type ModuleEnv elt = UniqFM elt type ModuleEnv elt = UniqFM elt
-- A ModuleName and Module have the same Unique,
-- so both will work as keys.
-- The 'ByName' variants work on ModuleNames
emptyModuleEnv :: ModuleEnv a emptyModuleEnv :: ModuleEnv a
mkModuleEnv :: [(Module, a)] -> ModuleEnv a mkModuleEnv :: [(Module, a)] -> ModuleEnv a
...@@ -338,14 +181,8 @@ lookupWithDefaultModuleEnv :: ModuleEnv a -> a -> Module -> a ...@@ -338,14 +181,8 @@ lookupWithDefaultModuleEnv :: ModuleEnv a -> a -> Module -> a
elemModuleEnv :: Module -> ModuleEnv a -> Bool elemModuleEnv :: Module -> ModuleEnv a -> Bool
foldModuleEnv :: (a -> b -> b) -> b -> ModuleEnv a -> b foldModuleEnv :: (a -> b -> b) -> b -> ModuleEnv a -> b
-- The ByName variants
lookupModuleEnvByName :: ModuleEnv a -> ModuleName -> Maybe a
unitModuleEnvByName :: ModuleName -> a -> ModuleEnv a
extendModuleEnvByName :: ModuleEnv a -> ModuleName -> a -> ModuleEnv a
elemModuleEnv = elemUFM elemModuleEnv = elemUFM
extendModuleEnv = addToUFM extendModuleEnv = addToUFM
extendModuleEnvByName = addToUFM
extendModuleEnv_C = addToUFM_C extendModuleEnv_C = addToUFM_C
extendModuleEnvList = addListToUFM extendModuleEnvList = addListToUFM
plusModuleEnv_C = plusUFM_C plusModuleEnv_C = plusUFM_C
...@@ -353,20 +190,17 @@ delModuleEnvList = delListFromUFM ...@@ -353,20 +190,17 @@ delModuleEnvList = delListFromUFM
delModuleEnv = delFromUFM delModuleEnv = delFromUFM
plusModuleEnv = plusUFM plusModuleEnv = plusUFM
lookupModuleEnv = lookupUFM lookupModuleEnv = lookupUFM
lookupModuleEnvByName = lookupUFM
lookupWithDefaultModuleEnv = lookupWithDefaultUFM lookupWithDefaultModuleEnv = lookupWithDefaultUFM
mapModuleEnv = mapUFM mapModuleEnv = mapUFM
mkModuleEnv = listToUFM mkModuleEnv = listToUFM
emptyModuleEnv = emptyUFM emptyModuleEnv = emptyUFM
moduleEnvElts = eltsUFM moduleEnvElts = eltsUFM
unitModuleEnv = unitUFM unitModuleEnv = unitUFM
unitModuleEnvByName = unitUFM
isEmptyModuleEnv = isNullUFM isEmptyModuleEnv = isNullUFM
foldModuleEnv = foldUFM foldModuleEnv = foldUFM
\end{code} \end{code}
\begin{code} \begin{code}
type ModuleSet = UniqSet Module type ModuleSet = UniqSet Module
mkModuleSet :: [Module] -> ModuleSet mkModuleSet :: [Module] -> ModuleSet
extendModuleSet :: ModuleSet -> Module -> ModuleSet extendModuleSet :: ModuleSet -> Module -> ModuleSet
......
...@@ -17,16 +17,16 @@ module Name ( ...@@ -17,16 +17,16 @@ module Name (
mkExternalName, mkWiredInName, mkExternalName, mkWiredInName,
nameUnique, setNameUnique, nameUnique, setNameUnique,
nameOccName, nameModule, nameModule_maybe, nameModuleName, nameOccName, nameModule, nameModule_maybe,
setNameOcc, setNameOcc,
hashName, localiseName, hashName, localiseName,
nameSrcLoc, nameParent, nameParent_maybe, nameSrcLoc, nameParent, nameParent_maybe,
isSystemName, isInternalName, isExternalName, isSystemName, isInternalName, isExternalName,
isTyVarName, isDllName, isWiredInName, isBuiltInSyntax, isTyVarName, isWiredInName, isBuiltInSyntax,
wiredInNameTyThing_maybe, wiredInNameTyThing_maybe,
nameIsLocalOrFrom, isHomePackageName, nameIsLocalOrFrom,
-- Class NamedThing and overloaded friends -- Class NamedThing and overloaded friends
NamedThing(..), NamedThing(..),
...@@ -38,8 +38,7 @@ module Name ( ...@@ -38,8 +38,7 @@ module Name (
import {-# SOURCE #-} TypeRep( TyThing ) import {-# SOURCE #-} TypeRep( TyThing )
import OccName -- All of it import OccName -- All of it
import Module ( Module, ModuleName, moduleName, isHomeModule ) import Module ( Module )
import CmdLineOpts ( opt_Static )
import SrcLoc ( noSrcLoc, wiredInSrcLoc, SrcLoc ) import SrcLoc ( noSrcLoc, wiredInSrcLoc, SrcLoc )
import Unique ( Unique, Uniquable(..), getKey, pprUnique ) import Unique ( Unique, Uniquable(..), getKey, pprUnique )
import Maybes ( orElse ) import Maybes ( orElse )
...@@ -120,7 +119,6 @@ All built-in syntax is for wired-in things. ...@@ -120,7 +119,6 @@ All built-in syntax is for wired-in things.
nameUnique :: Name -> Unique nameUnique :: Name -> Unique
nameOccName :: Name -> OccName nameOccName :: Name -> OccName
nameModule :: Name -> Module nameModule :: Name -> Module
nameModuleName :: Name -> ModuleName
nameSrcLoc :: Name -> SrcLoc nameSrcLoc :: Name -> SrcLoc
nameUnique name = n_uniq name nameUnique name = n_uniq name
...@@ -133,7 +131,6 @@ nameIsLocalOrFrom :: Module -> Name -> Bool ...@@ -133,7 +131,6 @@ nameIsLocalOrFrom :: Module -> Name -> Bool
isInternalName :: Name -> Bool isInternalName :: Name -> Bool
isExternalName :: Name -> Bool isExternalName :: Name -> Bool
isSystemName :: Name -> Bool isSystemName :: Name -> Bool
isHomePackageName :: Name -> Bool
isWiredInName :: Name -> Bool isWiredInName :: Name -> Bool
isWiredInName (Name {n_sort = WiredIn _ _ _ _}) = True isWiredInName (Name {n_sort = WiredIn _ _ _ _}) = True
...@@ -163,8 +160,6 @@ nameParent name = case nameParent_maybe name of ...@@ -163,8 +160,6 @@ nameParent name = case nameParent_maybe name of
Nothing -> name Nothing -> name
nameModule name = nameModule_maybe name `orElse` pprPanic "nameModule" (ppr name) nameModule name = nameModule_maybe name `orElse` pprPanic "nameModule" (ppr name)
nameModuleName name = moduleName (nameModule name)
nameModule_maybe (Name { n_sort = External mod _}) = Just mod nameModule_maybe (Name { n_sort = External mod _}) = Just mod
nameModule_maybe (Name { n_sort = WiredIn mod _ _ _}) = Just mod nameModule_maybe (Name { n_sort = WiredIn mod _ _ _}) = Just mod
nameModule_maybe name = Nothing nameModule_maybe name = Nothing
...@@ -173,13 +168,6 @@ nameIsLocalOrFrom from name ...@@ -173,13 +168,6 @@ nameIsLocalOrFrom from name
| isExternalName name = from == nameModule name | isExternalName name = from == nameModule name
| otherwise = True | otherwise = True
isHomePackageName name
| isExternalName name = isHomeModule (nameModule name)
| otherwise = True -- Internal and system names
isDllName :: Name -> Bool -- Does this name refer to something in a different DLL?
isDllName nm = not opt_Static && not (isHomePackageName nm)
isTyVarName :: Name -> Bool isTyVarName :: Name -> Bool
isTyVarName name = isTvOcc (nameOccName name) isTyVarName name = isTvOcc (nameOccName name)
...@@ -326,20 +314,18 @@ pprName (Name {n_sort = sort, n_uniq = uniq, n_occ = occ}) ...@@ -326,20 +314,18 @@ pprName (Name {n_sort = sort, n_uniq = uniq, n_occ = occ})
Internal -> pprInternal sty uniq occ Internal -> pprInternal sty uniq occ
pprExternal sty uniq mod occ is_wired is_builtin pprExternal sty uniq mod occ is_wired is_builtin
| codeStyle sty = ppr mod_name <> char '_' <> ppr_occ_name occ | codeStyle sty = ppr mod <> char '_' <> ppr_occ_name occ
-- In code style, always qualify -- In code style, always qualify
-- ToDo: maybe we could print all wired-in things unqualified -- ToDo: maybe we could print all wired-in things unqualified
-- in code style, to reduce symbol table bloat? -- in code style, to reduce symbol table bloat?
| debugStyle sty = ppr mod_name <> dot <> ppr_occ_name occ | debugStyle sty = ppr mod <> dot <> ppr_occ_name occ
<> braces (hsep [if is_wired then ptext SLIT("(w)") else empty, <> braces (hsep [if is_wired then ptext SLIT("(w)") else empty,
text (briefOccNameFlavour occ), text (briefOccNameFlavour occ),
pprUnique uniq]) pprUnique uniq])
| BuiltInSyntax <- is_builtin = ppr_occ_name occ | BuiltInSyntax <- is_builtin = ppr_occ_name occ
-- never qualify builtin syntax -- never qualify builtin syntax
| unqualStyle sty mod_name occ = ppr_occ_name occ | unqualStyle sty mod occ = ppr_occ_name occ
| otherwise = ppr mod_name <> dot <> ppr_occ_name occ | otherwise = ppr mod <> dot <> ppr_occ_name occ
where
mod_name = moduleName mod
pprInternal sty uniq occ pprInternal sty uniq occ
| codeStyle sty = pprUnique uniq | codeStyle sty = pprUnique uniq
......
...@@ -47,8 +47,8 @@ import OccName ( NameSpace, varName, ...@@ -47,8 +47,8 @@ import OccName ( NameSpace, varName,
elemOccEnv, plusOccEnv_C, extendOccEnv_C, foldOccEnv, elemOccEnv, plusOccEnv_C, extendOccEnv_C, foldOccEnv,
occEnvElts occEnvElts
) )
import Module ( ModuleName, mkModuleNameFS ) import Module ( Module, mkModuleFS )
import Name ( Name, NamedThing(getName), nameModuleName, nameParent_maybe, import Name ( Name, NamedThing(getName), nameModule, nameParent_maybe,
nameOccName, isExternalName, nameSrcLoc ) nameOccName, isExternalName, nameSrcLoc )
import SrcLoc ( isGoodSrcLoc, SrcSpan ) import SrcLoc ( isGoodSrcLoc, SrcSpan )
import Outputable import Outputable
...@@ -67,13 +67,13 @@ data RdrName ...@@ -67,13 +67,13 @@ data RdrName
= Unqual OccName = Unqual OccName
-- Used for ordinary, unqualified occurrences -- Used for ordinary, unqualified occurrences
| Qual ModuleName OccName | Qual Module OccName
-- A qualified name written by the user in -- A qualified name written by the user in
-- *source* code. The module isn't necessarily -- *source* code. The module isn't necessarily
-- the module where the thing is defined; -- the module where the thing is defined;
-- just the one from which it is imported -- just the one from which it is imported
| Orig ModuleName OccName | Orig Module OccName
-- An original name; the module is the *defining* module. -- An original name; the module is the *defining* module.
-- This is used when GHC generates code that will be fed -- This is used when GHC generates code that will be fed
-- into the renamer (e.g. from deriving clauses), but where -- into the renamer (e.g. from deriving clauses), but where
...@@ -97,10 +97,10 @@ data RdrName ...@@ -97,10 +97,10 @@ data RdrName
%************************************************************************ %************************************************************************
\begin{code} \begin{code}
rdrNameModule :: RdrName -> ModuleName rdrNameModule :: RdrName -> Module
rdrNameModule (Qual m _) = m rdrNameModule (Qual m _) = m
rdrNameModule (Orig m _) = m rdrNameModule (Orig m _) = m
rdrNameModule (Exact n) = nameModuleName n rdrNameModule (Exact n) = nameModule n
rdrNameModule (Unqual n) = pprPanic "rdrNameModule" (ppr n) rdrNameModule (Unqual n) = pprPanic "rdrNameModule" (ppr n)
rdrNameOcc :: RdrName -> OccName rdrNameOcc :: RdrName -> OccName
...@@ -121,7 +121,7 @@ setRdrNameSpace :: RdrName -> NameSpace -> RdrName ...@@ -121,7 +121,7 @@ setRdrNameSpace :: RdrName -> NameSpace -> RdrName
setRdrNameSpace (Unqual occ) ns = Unqual (setOccNameSpace ns occ) setRdrNameSpace (Unqual occ) ns = Unqual (setOccNameSpace ns occ)
setRdrNameSpace (Qual m occ) ns = Qual m (setOccNameSpace ns occ)