summaryrefslogtreecommitdiff
path: root/compiler/utils/GhcPrelude.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/utils/GhcPrelude.hs')
-rw-r--r--compiler/utils/GhcPrelude.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/compiler/utils/GhcPrelude.hs b/compiler/utils/GhcPrelude.hs
new file mode 100644
index 0000000000..66d01be5f8
--- /dev/null
+++ b/compiler/utils/GhcPrelude.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE CPP #-}
+
+-- | 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
+
+-- We export the 'Semigroup' class but w/o the (<>) operator to avoid
+-- clashing with the (Outputable.<>) operator which is heavily used
+-- through GHC's code-base.
+
+#if MIN_VERSION_base(4,11,0)
+import Prelude as X hiding ((<>))
+#else
+import Prelude as X
+import Data.Semigroup as X (Semigroup)
+#endif
+
+import Data.Foldable as X (foldl')
+
+{-
+Note [Why do we import Prelude here?]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+The files ghc-boot-th.cabal, ghc-boot.cabal, ghci.cabal and
+ghc-heap.cabal contain the directive default-extensions:
+NoImplicitPrelude. There are two motivations for this:
+ - Consistency with the compiler directory, which enables
+ NoImplicitPrelude;
+ - Allows loading the above dependent packages with ghc-in-ghci,
+ giving a smoother development experience when adding new
+ extensions.
+-}