Commit f63bc730 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺 Committed by Ben Gamari

compiler: introduce custom "GhcPrelude" Prelude

This switches the compiler/ component to get compiled with
-XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
modules.

This is motivated by the upcoming "Prelude" re-export of
`Semigroup((<>))` which would cause lots of name clashes in every
modulewhich imports also `Outputable`

Reviewers: austin, goldfire, bgamari, alanz, simonmar

Reviewed By: bgamari

Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari

Differential Revision: https://phabricator.haskell.org/D3989
parent 12a92fed
......@@ -17,6 +17,8 @@ module BkpSyn (
LRenaming, Renaming(..),
) where
import GhcPrelude
import HsSyn
import SrcLoc
import Outputable
......
......@@ -18,6 +18,8 @@ module DriverBkp (doBackpack) where
#include "HsVersions.h"
import GhcPrelude
-- In a separate module because it hooks into the parser.
import BkpSyn
......
......@@ -12,6 +12,8 @@ module NameShape(
#include "HsVersions.h"
import GhcPrelude
import Outputable
import HscTypes
import Module
......
......@@ -15,6 +15,8 @@ module RnModIface(
#include "HsVersions.h"
import GhcPrelude
import SrcLoc
import Outputable
import HscTypes
......
......@@ -26,6 +26,8 @@ module Avail (
) where
import GhcPrelude
import Name
import NameEnv
import NameSet
......
......@@ -109,6 +109,8 @@ module BasicTypes(
SpliceExplicitFlag(..)
) where
import GhcPrelude
import FastString
import Outputable
import SrcLoc ( Located,unLoc )
......
......@@ -26,6 +26,8 @@ module ConLike (
#include "HsVersions.h"
import GhcPrelude
import DataCon
import PatSyn
import Outputable
......
......@@ -61,6 +61,8 @@ module DataCon (
#include "HsVersions.h"
import GhcPrelude
import {-# SOURCE #-} MkId( DataConBoxer )
import Type
import ForeignCall ( CType )
......
module DataCon where
import GhcPrelude
import Var( TyVar, TyVarBinder )
import Name( Name, NamedThing )
import {-# SOURCE #-} TyCon( TyCon )
......
......@@ -62,6 +62,8 @@ module Demand (
#include "HsVersions.h"
import GhcPrelude
import DynFlags
import Outputable
import Var ( Var )
......
......@@ -69,6 +69,8 @@ module FieldLabel ( FieldLabelString
, mkFieldLabelOccs
) where
import GhcPrelude
import OccName
import Name
......
......@@ -116,6 +116,8 @@ module Id (
#include "HsVersions.h"
import GhcPrelude
import DynFlags
import CoreSyn ( CoreRule, isStableUnfolding, evaldUnfolding, Unfolding( NoUnfolding ) )
......
......@@ -82,6 +82,8 @@ module IdInfo (
#include "HsVersions.h"
import GhcPrelude
import CoreSyn
import Class
......
module IdInfo where
import GhcPrelude
import Outputable
data IdInfo
data IdDetails
......
......@@ -27,6 +27,8 @@ module Lexeme (
) where
import GhcPrelude
import FastString
import Data.Char
......
......@@ -44,6 +44,8 @@ module Literal
#include "HsVersions.h"
import GhcPrelude
import TysPrim
import PrelNames
import Type
......
......@@ -39,6 +39,8 @@ module MkId (
#include "HsVersions.h"
import GhcPrelude
import Rules
import TysPrim
import TysWiredIn
......
......@@ -137,6 +137,8 @@ module Module
unitModuleSet
) where
import GhcPrelude
import Config
import Outputable
import Unique
......
module Module where
import GhcPrelude
import FastString
data Module
......
......@@ -77,6 +77,8 @@ module Name (
module OccName
) where
import GhcPrelude
import {-# SOURCE #-} TyCoRep( TyThing )
import {-# SOURCE #-} PrelNames( starKindTyConKey, unicodeStarKindTyConKey )
......
module Name where
import GhcPrelude ()
data Name
......@@ -10,6 +10,8 @@ module NameCache
, NameCache(..), OrigNameCache
) where
import GhcPrelude
import Module
import Name
import UniqSupply
......
......@@ -33,6 +33,8 @@ module NameEnv (
#include "HsVersions.h"
import GhcPrelude
import Digraph
import Name
import UniqFM
......
......@@ -33,6 +33,8 @@ module NameSet (
#include "HsVersions.h"
import GhcPrelude
import Name
import UniqSet
import Data.List (sortBy)
......
......@@ -105,6 +105,8 @@ module OccName (
FastStringEnv, emptyFsEnv, lookupFsEnv, extendFsEnv, mkFsEnv
) where
import GhcPrelude
import Util
import Unique
import DynFlags
......
module OccName where
import GhcPrelude ()
data OccName
......@@ -24,6 +24,8 @@ module PatSyn (
#include "HsVersions.h"
import GhcPrelude
import Type
import Name
import Outputable
......
......@@ -67,6 +67,8 @@ module RdrName (
#include "HsVersions.h"
import GhcPrelude
import Module
import Name
import Avail
......
......@@ -77,6 +77,8 @@ module SrcLoc (
spans, isSubspanOf, sortLocated
) where
import GhcPrelude
import Util
import Json
import Outputable
......
......@@ -29,6 +29,8 @@ module UniqSupply (
initUniqSupply
) where
import GhcPrelude
import Unique
import GHC.IO
......
......@@ -68,6 +68,8 @@ module Unique (
#include "HsVersions.h"
#include "Unique.h"
import GhcPrelude
import BasicTypes
import FastString
import Outputable
......
......@@ -82,6 +82,8 @@ module Var (
#include "HsVersions.h"
import GhcPrelude
import {-# SOURCE #-} TyCoRep( Type, Kind, pprKind )
import {-# SOURCE #-} TcType( TcTyVarDetails, pprTcTyVarDetails, vanillaSkolemTv )
import {-# SOURCE #-} IdInfo( IdDetails, IdInfo, coVarDetails, isCoVarDetails,
......
......@@ -73,6 +73,8 @@ module VarEnv (
emptyTidyEnv
) where
import GhcPrelude
import OccName
import Var
import VarSet
......
......@@ -45,6 +45,8 @@ module VarSet (
#include "HsVersions.h"
import GhcPrelude
import Var ( Var, TyVar, CoVar, TyCoVar, Id )
import Unique
import Name ( Name )
......
......@@ -18,6 +18,8 @@ module Bitmap (
#include "HsVersions.h"
#include "../includes/MachDeps.h"
import GhcPrelude
import SMRep
import DynFlags
import Util
......
......@@ -8,6 +8,8 @@ module BlockId
, blockLbl, infoTblLbl
) where
import GhcPrelude
import CLabel
import IdInfo
import Name
......
......@@ -115,6 +115,8 @@ module CLabel (
#include "HsVersions.h"
import GhcPrelude
import IdInfo
import BasicTypes
import Packages
......
......@@ -26,6 +26,8 @@ module Cmm (
module CmmExpr,
) where
import GhcPrelude
import CLabel
import BlockId
import CmmNode
......
......@@ -7,6 +7,8 @@ where
#include "HsVersions.h"
import GhcPrelude hiding (succ)
import Hoopl.Block
import Hoopl.Graph
import Hoopl.Label
......@@ -34,9 +36,6 @@ import Data.Set (Set)
import qualified Data.Set as Set
import Control.Monad
import qualified Prelude as P
import Prelude hiding (succ)
foldSet :: (a -> b -> b) -> b -> Set a -> b
foldSet = Set.foldr
......@@ -220,7 +219,7 @@ procpointSRT dflags top_srt top_table entries =
sorted_ints = sort ints
offset = head sorted_ints
bitmap_entries = map (subtract offset) sorted_ints
len = P.last bitmap_entries + 1
len = GhcPrelude.last bitmap_entries + 1
bitmap = intsToBitmap dflags len bitmap_entries
maxBmpSize :: DynFlags -> Int
......
......@@ -9,6 +9,8 @@ module CmmCallConv (
#include "HsVersions.h"
import GhcPrelude
import CmmExpr
import SMRep
import Cmm (Convention(..))
......
......@@ -5,13 +5,14 @@ module CmmCommonBlockElim
where
import GhcPrelude hiding (iterate, succ, unzip, zip)
import BlockId
import Cmm
import CmmUtils
import CmmSwitch (eqSwitchTargetWith)
import CmmContFlowOpt
-- import PprCmm ()
import Prelude hiding (iterate, succ, unzip, zip)
import Hoopl.Block
import Hoopl.Graph
......
......@@ -9,6 +9,8 @@ module CmmContFlowOpt
)
where
import GhcPrelude hiding (succ, unzip, zip)
import Hoopl.Block
import Hoopl.Collections
import Hoopl.Graph
......@@ -22,7 +24,6 @@ import Panic
import Util
import Control.Monad
import Prelude hiding (succ, unzip, zip)
-- Note [What is shortcutting]
......
......@@ -28,6 +28,8 @@ module CmmExpr
)
where
import GhcPrelude
import BlockId
import CLabel
import CmmMachOp
......
......@@ -4,6 +4,8 @@ module CmmImplementSwitchPlans
)
where
import GhcPrelude
import Hoopl.Block
import BlockId
import Cmm
......
......@@ -34,6 +34,8 @@ module CmmInfo (
#include "HsVersions.h"
import GhcPrelude
import Cmm
import CmmUtils
import CLabel
......
......@@ -3,6 +3,8 @@ module CmmLayoutStack (
cmmLayoutStack, setInfoTableStackMap
) where
import GhcPrelude hiding ((<*>))
import StgCmmUtils ( callerSaveVolatileRegs ) -- XXX layering violation
import StgCmmForeign ( saveThreadState, loadThreadState ) -- XXX layering violation
......@@ -37,8 +39,6 @@ import Data.Array as Array
import Data.Bits
import Data.List (nub)
import Prelude hiding ((<*>))
#include "HsVersions.h"
{- Note [Stack Layout]
......
......@@ -22,6 +22,8 @@ module CmmLex (
CmmToken(..), cmmlex,
) where
import GhcPrelude
import CmmExpr
import Lexer
......
......@@ -10,6 +10,8 @@ module CmmLint (
cmmLint, cmmLintGraph
) where
import GhcPrelude
import Hoopl.Block
import Hoopl.Collections
import Hoopl.Graph
......
......@@ -12,6 +12,8 @@ module CmmLive
)
where
import GhcPrelude
import DynFlags
import BlockId
import Cmm
......
......@@ -30,6 +30,8 @@ where
#include "HsVersions.h"
import GhcPrelude
import CmmType
import Outputable
import DynFlags
......
......@@ -12,6 +12,8 @@ module CmmMonad (
, liftP
) where
import GhcPrelude