diff options
author | Simon Marlow <marlowsd@gmail.com> | 2008-08-05 13:35:44 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2008-08-05 13:35:44 +0000 |
commit | 1867a7bb8c59ea514b4f47f5434842543933ec9a (patch) | |
tree | 4f622970ba88bf408e2884d0ea3819230abf1232 /compiler/main/HeaderInfo.hs | |
parent | ea9a5be67418ab76c4fa33736a3335b517c9e7f9 (diff) | |
download | haskell-1867a7bb8c59ea514b4f47f5434842543933ec9a.tar.gz |
Add -XPackageImports, new syntax for package-qualified imports
Now you can say
import "network" Network.Socket
and get Network.Socket from package "network", even if there are
multiple Network.Socket modules in scope from different packages
and/or the current package.
This is not really intended for general use, it's mainly so that we
can build backwards-compatible versions of packages, where we need to
be able to do
module GHC.Base (module New.GHC.Base) where
import "base" GHC.Base as New.GHC.Base
Diffstat (limited to 'compiler/main/HeaderInfo.hs')
-rw-r--r-- | compiler/main/HeaderInfo.hs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/main/HeaderInfo.hs b/compiler/main/HeaderInfo.hs index d0e30e0617..eea6b52fc2 100644 --- a/compiler/main/HeaderInfo.hs +++ b/compiler/main/HeaderInfo.hs @@ -61,8 +61,9 @@ getImports dflags buf filename source_filename = do let main_loc = mkSrcLoc (mkFastString source_filename) 1 0 mod = mb_mod `orElse` L (srcLocSpan main_loc) mAIN_NAME - (src_idecls, ord_idecls) = partition isSourceIdecl (map unLoc imps) - source_imps = map getImpMod src_idecls + imps' = filter isHomeImp (map unLoc imps) + (src_idecls, ord_idecls) = partition isSourceIdecl imps' + source_imps = map getImpMod src_idecls ordinary_imps = filter ((/= moduleName gHC_PRIM) . unLoc) (map getImpMod ord_idecls) -- GHC.Prim doesn't exist physically, so don't go looking for it. @@ -72,11 +73,16 @@ getImports dflags buf filename source_filename = do parseError :: SrcSpan -> Message -> a parseError span err = throwErrMsg $ mkPlainErrMsg span err +-- we aren't interested in package imports here, filter them out +isHomeImp :: ImportDecl name -> Bool +isHomeImp (ImportDecl _ (Just p) _ _ _ _) = p == fsLit "this" +isHomeImp (ImportDecl _ Nothing _ _ _ _) = True + isSourceIdecl :: ImportDecl name -> Bool -isSourceIdecl (ImportDecl _ s _ _ _) = s +isSourceIdecl (ImportDecl _ _ s _ _ _) = s getImpMod :: ImportDecl name -> Located ModuleName -getImpMod (ImportDecl located_mod _ _ _ _) = located_mod +getImpMod (ImportDecl located_mod _ _ _ _ _) = located_mod -------------------------------------------------------------- -- Get options |