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 ( ...@@ -17,6 +17,8 @@ module BkpSyn (
LRenaming, Renaming(..), LRenaming, Renaming(..),
) where ) where
import GhcPrelude
import HsSyn import HsSyn
import SrcLoc import SrcLoc
import Outputable import Outputable
......
...@@ -18,6 +18,8 @@ module DriverBkp (doBackpack) where ...@@ -18,6 +18,8 @@ module DriverBkp (doBackpack) where
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
-- In a separate module because it hooks into the parser. -- In a separate module because it hooks into the parser.
import BkpSyn import BkpSyn
......
...@@ -12,6 +12,8 @@ module NameShape( ...@@ -12,6 +12,8 @@ module NameShape(
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import Outputable import Outputable
import HscTypes import HscTypes
import Module import Module
......
...@@ -15,6 +15,8 @@ module RnModIface( ...@@ -15,6 +15,8 @@ module RnModIface(
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import SrcLoc import SrcLoc
import Outputable import Outputable
import HscTypes import HscTypes
......
...@@ -26,6 +26,8 @@ module Avail ( ...@@ -26,6 +26,8 @@ module Avail (
) where ) where
import GhcPrelude
import Name import Name
import NameEnv import NameEnv
import NameSet import NameSet
......
...@@ -109,6 +109,8 @@ module BasicTypes( ...@@ -109,6 +109,8 @@ module BasicTypes(
SpliceExplicitFlag(..) SpliceExplicitFlag(..)
) where ) where
import GhcPrelude
import FastString import FastString
import Outputable import Outputable
import SrcLoc ( Located,unLoc ) import SrcLoc ( Located,unLoc )
......
...@@ -26,6 +26,8 @@ module ConLike ( ...@@ -26,6 +26,8 @@ module ConLike (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import DataCon import DataCon
import PatSyn import PatSyn
import Outputable import Outputable
......
...@@ -61,6 +61,8 @@ module DataCon ( ...@@ -61,6 +61,8 @@ module DataCon (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import {-# SOURCE #-} MkId( DataConBoxer ) import {-# SOURCE #-} MkId( DataConBoxer )
import Type import Type
import ForeignCall ( CType ) import ForeignCall ( CType )
......
module DataCon where module DataCon where
import GhcPrelude
import Var( TyVar, TyVarBinder ) import Var( TyVar, TyVarBinder )
import Name( Name, NamedThing ) import Name( Name, NamedThing )
import {-# SOURCE #-} TyCon( TyCon ) import {-# SOURCE #-} TyCon( TyCon )
......
...@@ -62,6 +62,8 @@ module Demand ( ...@@ -62,6 +62,8 @@ module Demand (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import DynFlags import DynFlags
import Outputable import Outputable
import Var ( Var ) import Var ( Var )
......
...@@ -69,6 +69,8 @@ module FieldLabel ( FieldLabelString ...@@ -69,6 +69,8 @@ module FieldLabel ( FieldLabelString
, mkFieldLabelOccs , mkFieldLabelOccs
) where ) where
import GhcPrelude
import OccName import OccName
import Name import Name
......
...@@ -116,6 +116,8 @@ module Id ( ...@@ -116,6 +116,8 @@ module Id (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import DynFlags import DynFlags
import CoreSyn ( CoreRule, isStableUnfolding, evaldUnfolding, Unfolding( NoUnfolding ) ) import CoreSyn ( CoreRule, isStableUnfolding, evaldUnfolding, Unfolding( NoUnfolding ) )
......
...@@ -82,6 +82,8 @@ module IdInfo ( ...@@ -82,6 +82,8 @@ module IdInfo (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import CoreSyn import CoreSyn
import Class import Class
......
module IdInfo where module IdInfo where
import GhcPrelude
import Outputable import Outputable
data IdInfo data IdInfo
data IdDetails data IdDetails
......
...@@ -27,6 +27,8 @@ module Lexeme ( ...@@ -27,6 +27,8 @@ module Lexeme (
) where ) where
import GhcPrelude
import FastString import FastString
import Data.Char import Data.Char
......
...@@ -44,6 +44,8 @@ module Literal ...@@ -44,6 +44,8 @@ module Literal
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import TysPrim import TysPrim
import PrelNames import PrelNames
import Type import Type
......
...@@ -39,6 +39,8 @@ module MkId ( ...@@ -39,6 +39,8 @@ module MkId (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import Rules import Rules
import TysPrim import TysPrim
import TysWiredIn import TysWiredIn
......
...@@ -137,6 +137,8 @@ module Module ...@@ -137,6 +137,8 @@ module Module
unitModuleSet unitModuleSet
) where ) where
import GhcPrelude
import Config import Config
import Outputable import Outputable
import Unique import Unique
......
module Module where module Module where
import GhcPrelude
import FastString import FastString
data Module data Module
......
...@@ -77,6 +77,8 @@ module Name ( ...@@ -77,6 +77,8 @@ module Name (
module OccName module OccName
) where ) where
import GhcPrelude
import {-# SOURCE #-} TyCoRep( TyThing ) import {-# SOURCE #-} TyCoRep( TyThing )
import {-# SOURCE #-} PrelNames( starKindTyConKey, unicodeStarKindTyConKey ) import {-# SOURCE #-} PrelNames( starKindTyConKey, unicodeStarKindTyConKey )
......
module Name where module Name where
import GhcPrelude ()
data Name data Name
...@@ -10,6 +10,8 @@ module NameCache ...@@ -10,6 +10,8 @@ module NameCache
, NameCache(..), OrigNameCache , NameCache(..), OrigNameCache
) where ) where
import GhcPrelude
import Module import Module
import Name import Name
import UniqSupply import UniqSupply
......
...@@ -33,6 +33,8 @@ module NameEnv ( ...@@ -33,6 +33,8 @@ module NameEnv (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import Digraph import Digraph
import Name import Name
import UniqFM import UniqFM
......
...@@ -33,6 +33,8 @@ module NameSet ( ...@@ -33,6 +33,8 @@ module NameSet (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import Name import Name
import UniqSet import UniqSet
import Data.List (sortBy) import Data.List (sortBy)
......
...@@ -105,6 +105,8 @@ module OccName ( ...@@ -105,6 +105,8 @@ module OccName (
FastStringEnv, emptyFsEnv, lookupFsEnv, extendFsEnv, mkFsEnv FastStringEnv, emptyFsEnv, lookupFsEnv, extendFsEnv, mkFsEnv
) where ) where
import GhcPrelude
import Util import Util
import Unique import Unique
import DynFlags import DynFlags
......
module OccName where module OccName where
import GhcPrelude ()
data OccName data OccName
...@@ -24,6 +24,8 @@ module PatSyn ( ...@@ -24,6 +24,8 @@ module PatSyn (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import Type import Type
import Name import Name
import Outputable import Outputable
......
...@@ -67,6 +67,8 @@ module RdrName ( ...@@ -67,6 +67,8 @@ module RdrName (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import Module import Module
import Name import Name
import Avail import Avail
......
...@@ -77,6 +77,8 @@ module SrcLoc ( ...@@ -77,6 +77,8 @@ module SrcLoc (
spans, isSubspanOf, sortLocated spans, isSubspanOf, sortLocated
) where ) where
import GhcPrelude
import Util import Util
import Json import Json
import Outputable import Outputable
......
...@@ -29,6 +29,8 @@ module UniqSupply ( ...@@ -29,6 +29,8 @@ module UniqSupply (
initUniqSupply initUniqSupply
) where ) where
import GhcPrelude
import Unique import Unique
import GHC.IO import GHC.IO
......
...@@ -68,6 +68,8 @@ module Unique ( ...@@ -68,6 +68,8 @@ module Unique (
#include "HsVersions.h" #include "HsVersions.h"
#include "Unique.h" #include "Unique.h"
import GhcPrelude
import BasicTypes import BasicTypes
import FastString import FastString
import Outputable import Outputable
......
...@@ -82,6 +82,8 @@ module Var ( ...@@ -82,6 +82,8 @@ module Var (
#include "HsVersions.h" #include "HsVersions.h"
import GhcPrelude
import {-# SOURCE #-} TyCoRep( Type, Kind, pprKind ) import {-# SOURCE #-} TyCoRep( Type, Kind, pprKind )
import {-# SOURCE #-} TcType( TcTyVarDetails, pprTcTyVarDetails, vanillaSkolemTv ) import {-# SOURCE #-} TcType( TcTyVarDetails, pprTcTyVarDetails, vanillaSkolemTv )
import {-# SOURCE #-} IdInfo( IdDetails, IdInfo, coVarDetails, isCoVarDetails, import {-# SOURCE #-} IdInfo( IdDetails, IdInfo, coVarDetails, isCoVarDetails,
......
...@@ -73,6 +73,8 @@ module VarEnv ( ...@@ -73,6 +73,8 @@ module VarEnv (
emptyTidyEnv emptyTidyEnv
) where ) where