#include "HsVersions.h"
-import CmdLineOpts ( DynFlag(..), opt_NoImplicitPrelude )
+import CmdLineOpts ( DynFlag(..) )
import HsSyn ( HsModule(..), HsDecl(..), IE(..), ieName, ImportDecl(..),
ForeignDecl(..), ForKind(..), isDynamicExtName,
-- PROCESS IMPORT DECLS
-- Do the non {- SOURCE -} ones first, so that we get a helpful
-- warning for {- SOURCE -} ones that are unnecessary
+ doptRn Opt_NoImplicitPrelude `thenRn` \ opt_no_prelude ->
let
+ all_imports = mk_prel_imports opt_no_prelude ++ imports
(source, ordinary) = partition is_source_import all_imports
is_source_import (ImportDecl _ ImportByUserSource _ _ _ _) = True
is_source_import other = False
)
where
this_mod_name = moduleName this_mod
- all_imports = prel_imports ++ imports
-- NB: opt_NoImplicitPrelude is slightly different to import Prelude ();
-- because the former doesn't even look at Prelude.hi for instance declarations,
-- whereas the latter does.
- prel_imports | this_mod_name == pRELUDE_Name ||
- explicit_prelude_import ||
- opt_NoImplicitPrelude
- = []
-
- | otherwise = [ImportDecl pRELUDE_Name
- ImportByUser
- False {- Not qualified -}
- Nothing {- No "as" -}
- Nothing {- No import list -}
- mod_loc]
+ mk_prel_imports no_prelude
+ | this_mod_name == pRELUDE_Name ||
+ explicit_prelude_import ||
+ no_prelude
+ = []
+
+ | otherwise = [ImportDecl pRELUDE_Name
+ ImportByUser
+ False {- Not qualified -}
+ Nothing {- No "as" -}
+ Nothing {- No import list -}
+ mod_loc]
explicit_prelude_import
= not (null [ () | (ImportDecl mod _ _ _ _ _) <- imports, mod == pRELUDE_Name ])
returnRn [avail]
| otherwise -- a foreign export
- = lookupOrigName nm `thenRn_`
- returnRn []
+ = returnRn []
where
binds_haskell_name (FoImport _) = True
binds_haskell_name FoLabel = True