diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2017-09-19 14:35:36 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-09-19 14:35:38 -0400 |
commit | f63bc730c7ea42ca6882f8078eb86be8bf1cc6ad (patch) | |
tree | 3273e53bf00121c2a2657a9fe997283300e997e9 /compiler/utils | |
parent | 12a92fedf8b1997f2e26800929be117d54536b7e (diff) | |
download | haskell-f63bc730c7ea42ca6882f8078eb86be8bf1cc6ad.tar.gz |
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
Diffstat (limited to 'compiler/utils')
45 files changed, 97 insertions, 1 deletions
diff --git a/compiler/utils/AsmUtils.hs b/compiler/utils/AsmUtils.hs index 55f9d6d551..36fb7ef6cb 100644 --- a/compiler/utils/AsmUtils.hs +++ b/compiler/utils/AsmUtils.hs @@ -6,6 +6,8 @@ module AsmUtils ( sectionType ) where +import GhcPrelude + import Platform import Outputable diff --git a/compiler/utils/Bag.hs b/compiler/utils/Bag.hs index fffbb6eb12..a027db23b7 100644 --- a/compiler/utils/Bag.hs +++ b/compiler/utils/Bag.hs @@ -25,6 +25,8 @@ module Bag ( anyBagM, filterBagM ) where +import GhcPrelude + import Outputable import Util diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs index 9254e97985..1c0284a332 100644 --- a/compiler/utils/Binary.hs +++ b/compiler/utils/Binary.hs @@ -59,6 +59,8 @@ module Binary -- The *host* architecture version: #include "../includes/MachDeps.h" +import GhcPrelude + import {-# SOURCE #-} Name (Name) import FastString import Panic diff --git a/compiler/utils/BooleanFormula.hs b/compiler/utils/BooleanFormula.hs index 43a71f0080..a42bb90a1c 100644 --- a/compiler/utils/BooleanFormula.hs +++ b/compiler/utils/BooleanFormula.hs @@ -16,6 +16,8 @@ module BooleanFormula ( pprBooleanFormula, pprBooleanFormulaNice ) where +import GhcPrelude + import Data.List ( nub, intersperse ) import Data.Data diff --git a/compiler/utils/BufWrite.hs b/compiler/utils/BufWrite.hs index eff57059de..e25bf06c4c 100644 --- a/compiler/utils/BufWrite.hs +++ b/compiler/utils/BufWrite.hs @@ -23,6 +23,8 @@ module BufWrite ( bFlush, ) where +import GhcPrelude + import FastString import FastMutInt diff --git a/compiler/utils/Digraph.hs b/compiler/utils/Digraph.hs index 3d9e5a39cb..c6f2706cec 100644 --- a/compiler/utils/Digraph.hs +++ b/compiler/utils/Digraph.hs @@ -40,6 +40,8 @@ module Digraph( ------------------------------------------------------------------------------ +import GhcPrelude + import Util ( minWith, count ) import Outputable import Maybes ( expectJust ) diff --git a/compiler/utils/Encoding.hs b/compiler/utils/Encoding.hs index f2b0979995..f809ba9016 100644 --- a/compiler/utils/Encoding.hs +++ b/compiler/utils/Encoding.hs @@ -33,6 +33,8 @@ module Encoding ( toBase62Padded ) where +import GhcPrelude + import Foreign import Foreign.ForeignPtr.Unsafe import Data.Char diff --git a/compiler/utils/EnumSet.hs b/compiler/utils/EnumSet.hs index aa36b788aa..99b93f5c22 100644 --- a/compiler/utils/EnumSet.hs +++ b/compiler/utils/EnumSet.hs @@ -10,6 +10,8 @@ module EnumSet , empty ) where +import GhcPrelude + import qualified Data.IntSet as IntSet newtype EnumSet a = EnumSet IntSet.IntSet diff --git a/compiler/utils/Exception.hs b/compiler/utils/Exception.hs index 850393e359..9d9b3ae25c 100644 --- a/compiler/utils/Exception.hs +++ b/compiler/utils/Exception.hs @@ -6,6 +6,8 @@ module Exception ) where +import GhcPrelude + import Control.Exception import Control.Monad.IO.Class diff --git a/compiler/utils/FV.hs b/compiler/utils/FV.hs index b5cf096aac..6d0dc2b2ab 100644 --- a/compiler/utils/FV.hs +++ b/compiler/utils/FV.hs @@ -26,6 +26,8 @@ module FV ( mapUnionFV, ) where +import GhcPrelude + import Var import VarSet diff --git a/compiler/utils/FastFunctions.hs b/compiler/utils/FastFunctions.hs index c643e3c8fb..be3f3cbee4 100644 --- a/compiler/utils/FastFunctions.hs +++ b/compiler/utils/FastFunctions.hs @@ -10,6 +10,8 @@ module FastFunctions ( #include "HsVersions.h" +import GhcPrelude () + import GHC.Exts import GHC.IO (IO(..)) diff --git a/compiler/utils/FastMutInt.hs b/compiler/utils/FastMutInt.hs index 2a6e7b83aa..6ba139a486 100644 --- a/compiler/utils/FastMutInt.hs +++ b/compiler/utils/FastMutInt.hs @@ -15,6 +15,8 @@ module FastMutInt( readFastMutPtr, writeFastMutPtr ) where +import GhcPrelude + import Data.Bits import GHC.Base import GHC.Ptr diff --git a/compiler/utils/FastString.hs b/compiler/utils/FastString.hs index ee6dd7a415..fde4ff01de 100644 --- a/compiler/utils/FastString.hs +++ b/compiler/utils/FastString.hs @@ -97,6 +97,8 @@ module FastString #include "HsVersions.h" +import GhcPrelude as Prelude + import Encoding import FastFunctions import Panic diff --git a/compiler/utils/FastStringEnv.hs b/compiler/utils/FastStringEnv.hs index 14b0859211..1b4af6cee7 100644 --- a/compiler/utils/FastStringEnv.hs +++ b/compiler/utils/FastStringEnv.hs @@ -27,6 +27,8 @@ module FastStringEnv ( mkDFsEnv, emptyDFsEnv, dFsEnvElts, lookupDFsEnv ) where +import GhcPrelude + import UniqFM import UniqDFM import Maybes diff --git a/compiler/utils/Fingerprint.hsc b/compiler/utils/Fingerprint.hsc index d4cee0e10b..4c89ec0893 100644 --- a/compiler/utils/Fingerprint.hsc +++ b/compiler/utils/Fingerprint.hsc @@ -24,6 +24,8 @@ module Fingerprint ( #include "md5.h" ##include "HsVersions.h" +import GhcPrelude + import Foreign import GHC.IO import Numeric ( readHex ) diff --git a/compiler/utils/FiniteMap.hs b/compiler/utils/FiniteMap.hs index cb6e5573e8..afa3636432 100644 --- a/compiler/utils/FiniteMap.hs +++ b/compiler/utils/FiniteMap.hs @@ -7,6 +7,8 @@ module FiniteMap ( foldRight, foldRightWithKey ) where +import GhcPrelude + import Data.Map (Map) import qualified Data.Map as Map diff --git a/compiler/utils/GhcPrelude.hs b/compiler/utils/GhcPrelude.hs new file mode 100644 index 0000000000..ed4eacbfb8 --- /dev/null +++ b/compiler/utils/GhcPrelude.hs @@ -0,0 +1,9 @@ +-- | Custom GHC "Prelude" +-- +-- This module serves as a replacement for the "Prelude" module +-- and abstracts over differences between the bootstrapping +-- GHC version, and may also provide a common default vocabulary. +-- +module GhcPrelude (module X) where + +import Prelude as X diff --git a/compiler/utils/GraphBase.hs b/compiler/utils/GraphBase.hs index c3850dfdd6..b66599356e 100644 --- a/compiler/utils/GraphBase.hs +++ b/compiler/utils/GraphBase.hs @@ -12,6 +12,8 @@ module GraphBase ( where +import GhcPrelude + import UniqSet import UniqFM diff --git a/compiler/utils/GraphColor.hs b/compiler/utils/GraphColor.hs index be7975b306..7affb92391 100644 --- a/compiler/utils/GraphColor.hs +++ b/compiler/utils/GraphColor.hs @@ -12,6 +12,8 @@ module GraphColor ( where +import GhcPrelude + import GraphBase import GraphOps import GraphPpr diff --git a/compiler/utils/GraphOps.hs b/compiler/utils/GraphOps.hs index 565134be92..bb4504ff1f 100644 --- a/compiler/utils/GraphOps.hs +++ b/compiler/utils/GraphOps.hs @@ -18,6 +18,8 @@ module GraphOps ( ) where +import GhcPrelude + import GraphBase import Outputable diff --git a/compiler/utils/GraphPpr.hs b/compiler/utils/GraphPpr.hs index a40e1058d0..c39395eda8 100644 --- a/compiler/utils/GraphPpr.hs +++ b/compiler/utils/GraphPpr.hs @@ -7,6 +7,8 @@ module GraphPpr ( ) where +import GhcPrelude + import GraphBase import Outputable diff --git a/compiler/utils/IOEnv.hs b/compiler/utils/IOEnv.hs index 6fc5f9dc67..b9210702fa 100644 --- a/compiler/utils/IOEnv.hs +++ b/compiler/utils/IOEnv.hs @@ -29,6 +29,8 @@ module IOEnv ( atomicUpdMutVar, atomicUpdMutVar' ) where +import GhcPrelude + import DynFlags import Exception import Module diff --git a/compiler/utils/Json.hs b/compiler/utils/Json.hs index ffbff50641..2bf00d3851 100644 --- a/compiler/utils/Json.hs +++ b/compiler/utils/Json.hs @@ -1,6 +1,8 @@ {-# LANGUAGE GADTs #-} module Json where +import GhcPrelude + import Outputable import Data.Char import Numeric diff --git a/compiler/utils/ListSetOps.hs b/compiler/utils/ListSetOps.hs index 7fa441402c..c311ac9c85 100644 --- a/compiler/utils/ListSetOps.hs +++ b/compiler/utils/ListSetOps.hs @@ -23,6 +23,8 @@ module ListSetOps ( #include "HsVersions.h" +import GhcPrelude + import Outputable import Util diff --git a/compiler/utils/ListT.hs b/compiler/utils/ListT.hs index 7dc1aa3eaf..c16701419d 100644 --- a/compiler/utils/ListT.hs +++ b/compiler/utils/ListT.hs @@ -29,6 +29,8 @@ module ListT ( fold ) where +import GhcPrelude + import Control.Applicative import Control.Monad diff --git a/compiler/utils/Maybes.hs b/compiler/utils/Maybes.hs index 89dd5b4fae..3a139a5b36 100644 --- a/compiler/utils/Maybes.hs +++ b/compiler/utils/Maybes.hs @@ -23,6 +23,8 @@ module Maybes ( MaybeT(..), liftMaybeT, tryMaybeT ) where +import GhcPrelude + import Control.Monad import Control.Monad.Trans.Maybe import Control.Exception (catch, SomeException(..)) diff --git a/compiler/utils/MonadUtils.hs b/compiler/utils/MonadUtils.hs index d6fb31731e..39a76e1cf2 100644 --- a/compiler/utils/MonadUtils.hs +++ b/compiler/utils/MonadUtils.hs @@ -27,6 +27,8 @@ module MonadUtils -- Imports ------------------------------------------------------------------------------- +import GhcPrelude + import Maybes import Control.Monad diff --git a/compiler/utils/OrdList.hs b/compiler/utils/OrdList.hs index 90fdefb908..081210a534 100644 --- a/compiler/utils/OrdList.hs +++ b/compiler/utils/OrdList.hs @@ -15,6 +15,8 @@ module OrdList ( mapOL, fromOL, toOL, foldrOL, foldlOL ) where +import GhcPrelude + import Outputable import Data.Semigroup ( Semigroup ) diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs index 5cd7656b4f..d257e3ec9f 100644 --- a/compiler/utils/Outputable.hs +++ b/compiler/utils/Outputable.hs @@ -85,6 +85,8 @@ module Outputable ( pprDebugAndThen, callStackDoc ) where +import GhcPrelude + import {-# SOURCE #-} DynFlags( DynFlags, hasPprDebug, hasNoDebugOutput, targetPlatform, pprUserLength, pprCols, useUnicode, useUnicodeSyntax, diff --git a/compiler/utils/Outputable.hs-boot b/compiler/utils/Outputable.hs-boot index 980c186889..ad7d091833 100644 --- a/compiler/utils/Outputable.hs-boot +++ b/compiler/utils/Outputable.hs-boot @@ -1,5 +1,7 @@ module Outputable where +import GhcPrelude + data SDoc showSDocUnsafe :: SDoc -> String diff --git a/compiler/utils/Pair.hs b/compiler/utils/Pair.hs index aeb8648b64..08b19be0b2 100644 --- a/compiler/utils/Pair.hs +++ b/compiler/utils/Pair.hs @@ -9,6 +9,8 @@ module Pair ( Pair(..), unPair, toPair, swap, pLiftFst, pLiftSnd ) where #include "HsVersions.h" +import GhcPrelude + import Outputable import qualified Data.Semigroup as Semi diff --git a/compiler/utils/Panic.hs b/compiler/utils/Panic.hs index 0a21f251fb..910906e08c 100644 --- a/compiler/utils/Panic.hs +++ b/compiler/utils/Panic.hs @@ -27,6 +27,8 @@ module Panic ( ) where #include "HsVersions.h" +import GhcPrelude + import {-# SOURCE #-} Outputable (SDoc, showSDocUnsafe) import Config diff --git a/compiler/utils/Platform.hs b/compiler/utils/Platform.hs index 8cd1fa75e3..c313870f2f 100644 --- a/compiler/utils/Platform.hs +++ b/compiler/utils/Platform.hs @@ -20,6 +20,8 @@ module Platform ( where +import GhcPrelude + -- | Contains enough information for the native code generator to emit -- code for this platform. data Platform diff --git a/compiler/utils/PprColour.hs b/compiler/utils/PprColour.hs index f8ea28faa9..f32b8b0084 100644 --- a/compiler/utils/PprColour.hs +++ b/compiler/utils/PprColour.hs @@ -1,4 +1,6 @@ module PprColour where +import GhcPrelude + import Data.Maybe (fromMaybe) import Util (OverridingBool(..), split) import Data.Semigroup as Semi diff --git a/compiler/utils/Pretty.hs b/compiler/utils/Pretty.hs index a4d67f03a0..78c8e6a885 100644 --- a/compiler/utils/Pretty.hs +++ b/compiler/utils/Pretty.hs @@ -111,11 +111,12 @@ module Pretty ( ) where +import GhcPrelude hiding (error) + import BufWrite import FastString import Panic import System.IO -import Prelude hiding (error) --for a RULES import GHC.Base ( unpackCString# ) diff --git a/compiler/utils/State.hs b/compiler/utils/State.hs index 8eca4657df..11bd7686d7 100644 --- a/compiler/utils/State.hs +++ b/compiler/utils/State.hs @@ -2,6 +2,8 @@ module State where +import GhcPrelude + newtype State s a = State { runState' :: s -> (# a, s #) } instance Functor (State s) where diff --git a/compiler/utils/Stream.hs b/compiler/utils/Stream.hs index f7b21017cf..ad01fad40c 100644 --- a/compiler/utils/Stream.hs +++ b/compiler/utils/Stream.hs @@ -11,6 +11,8 @@ module Stream ( Stream.map, Stream.mapM, Stream.mapAccumL ) where +import GhcPrelude + import Control.Monad -- | diff --git a/compiler/utils/StringBuffer.hs b/compiler/utils/StringBuffer.hs index d75e537fca..08402101af 100644 --- a/compiler/utils/StringBuffer.hs +++ b/compiler/utils/StringBuffer.hs @@ -45,6 +45,8 @@ module StringBuffer #include "HsVersions.h" +import GhcPrelude + import Encoding import FastString import FastFunctions diff --git a/compiler/utils/UnVarGraph.hs b/compiler/utils/UnVarGraph.hs index 228f3b5220..a540132bb7 100644 --- a/compiler/utils/UnVarGraph.hs +++ b/compiler/utils/UnVarGraph.hs @@ -27,6 +27,8 @@ module UnVarGraph , delNode ) where +import GhcPrelude + import Id import VarEnv import UniqFM diff --git a/compiler/utils/UniqDFM.hs b/compiler/utils/UniqDFM.hs index cb3dd7b7bd..715600ddb8 100644 --- a/compiler/utils/UniqDFM.hs +++ b/compiler/utils/UniqDFM.hs @@ -59,6 +59,8 @@ module UniqDFM ( alwaysUnsafeUfmToUdfm, ) where +import GhcPrelude + import Unique ( Uniquable(..), Unique, getKey ) import Outputable diff --git a/compiler/utils/UniqDSet.hs b/compiler/utils/UniqDSet.hs index eef545eedd..e33becf036 100644 --- a/compiler/utils/UniqDSet.hs +++ b/compiler/utils/UniqDSet.hs @@ -32,6 +32,8 @@ module UniqDSet ( partitionUniqDSet ) where +import GhcPrelude + import UniqDFM import UniqSet import Unique diff --git a/compiler/utils/UniqFM.hs b/compiler/utils/UniqFM.hs index 076479f984..f0cc197b71 100644 --- a/compiler/utils/UniqFM.hs +++ b/compiler/utils/UniqFM.hs @@ -71,6 +71,8 @@ module UniqFM ( pprUniqFM, pprUFM, pprUFMWithKeys, pluralUFM ) where +import GhcPrelude + import Unique ( Uniquable(..), Unique, getKey ) import Outputable diff --git a/compiler/utils/UniqMap.hs b/compiler/utils/UniqMap.hs index c0960dd5b2..2dd3cd57ea 100644 --- a/compiler/utils/UniqMap.hs +++ b/compiler/utils/UniqMap.hs @@ -44,6 +44,8 @@ module UniqMap ( -- Non-deterministic functions omitted ) where +import GhcPrelude + import UniqFM import Unique diff --git a/compiler/utils/UniqSet.hs b/compiler/utils/UniqSet.hs index d09b337d12..be600a09b3 100644 --- a/compiler/utils/UniqSet.hs +++ b/compiler/utils/UniqSet.hs @@ -46,6 +46,8 @@ module UniqSet ( nonDetFoldUniqSet_Directly ) where +import GhcPrelude + import UniqFM import Unique import Data.Coerce diff --git a/compiler/utils/Util.hs b/compiler/utils/Util.hs index 6146bf0113..3b402f2833 100644 --- a/compiler/utils/Util.hs +++ b/compiler/utils/Util.hs @@ -129,6 +129,8 @@ module Util ( #include "HsVersions.h" +import GhcPrelude + import Exception import Panic |