From 60ecf43a5a0b1cc732560058a06ca5b2f2e27773 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Thu, 26 Jul 2018 17:21:08 -0400 Subject: Modifications to support loading GHC into GHCi This change was previously part of [D4904](https://phabricator.haskell.org/D4904), but is being split off to aid in getting this reviewed and merged. * The compiler code is built with `NoImplicitPrelude`, but GHCi's modules are incompatible with it. So, this adds the pragma to all GHCi modules that didn't have it, and adds imports of Prelude. * In order to run GHC within itself, a `call of 'initGCStatistics` needed to be skipped. This uses CPP to skip it when `-DGHC_LOADED_INTO_GHCI` is set. * There is an environment variable workaround suggested by Ben Gamari [1], where `_GHC_TOP_DIR` can be used to specify GHC's top dir if `-B` isn't provided. This can be used to solve a problem where the GHC being run within GHCi attempts to look in `inplace/lib/lib/` instead of `inplace/lib/`. [1]: https://phabricator.haskell.org/D4904#135438 Reviewers: goldfire, bgamari, erikd, alpmestan Reviewed By: alpmestan Subscribers: alpmestan, lelf, rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4986 --- libraries/template-haskell/Language/Haskell/TH/Lib.hs | 1 + libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs | 1 + libraries/template-haskell/Language/Haskell/TH/Lib/Map.hs | 2 ++ libraries/template-haskell/Language/Haskell/TH/Quote.hs | 1 + libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 1 + libraries/template-haskell/template-haskell.cabal | 5 +++++ 6 files changed, 11 insertions(+) (limited to 'libraries/template-haskell') diff --git a/libraries/template-haskell/Language/Haskell/TH/Lib.hs b/libraries/template-haskell/Language/Haskell/TH/Lib.hs index b7966cefac..b0aa580d04 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Lib.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Lib.hs @@ -151,6 +151,7 @@ import Language.Haskell.TH.Lib.Internal hiding import Language.Haskell.TH.Syntax import Control.Monad (liftM2) +import Prelude -- All definitions below represent the "old" API, since their definitions are -- different in Language.Haskell.TH.Lib.Internal. Please think carefully before diff --git a/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs b/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs index cac8ea8643..0ddfddf23a 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs @@ -18,6 +18,7 @@ import Language.Haskell.TH.Syntax hiding (Role, InjectivityAnn) import qualified Language.Haskell.TH.Syntax as TH import Control.Monad( liftM, liftM2 ) import Data.Word( Word8 ) +import Prelude ---------------------------------------------------------- -- * Type synonyms diff --git a/libraries/template-haskell/Language/Haskell/TH/Lib/Map.hs b/libraries/template-haskell/Language/Haskell/TH/Lib/Map.hs index ac241515b8..b11139c2cb 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Lib/Map.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Lib/Map.hs @@ -16,6 +16,8 @@ module Language.Haskell.TH.Lib.Map , Language.Haskell.TH.Lib.Map.lookup ) where +import Prelude + data Map k a = Bin {-# UNPACK #-} !Size !k a !(Map k a) !(Map k a) | Tip diff --git a/libraries/template-haskell/Language/Haskell/TH/Quote.hs b/libraries/template-haskell/Language/Haskell/TH/Quote.hs index 91e37399e6..4ff5a2041b 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Quote.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Quote.hs @@ -21,6 +21,7 @@ module Language.Haskell.TH.Quote( ) where import Language.Haskell.TH.Syntax +import Prelude -- | The 'QuasiQuoter' type, a value @q@ of this type can be used -- in the syntax @[q| ... string to parse ...|]@. In fact, for diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index f5f60c38b4..4e0a1c9330 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -41,6 +41,7 @@ import GHC.Lexeme ( startsVarSym, startsVarId ) import GHC.ForeignSrcLang.Type import Language.Haskell.TH.LanguageExtensions import Numeric.Natural +import Prelude import qualified Control.Monad.Fail as Fail diff --git a/libraries/template-haskell/template-haskell.cabal b/libraries/template-haskell/template-haskell.cabal index 6cd156ccb6..2b2c5db463 100644 --- a/libraries/template-haskell/template-haskell.cabal +++ b/libraries/template-haskell/template-haskell.cabal @@ -60,3 +60,8 @@ Library -- We need to set the unit ID to template-haskell (without a -- version number) as it's magic. ghc-options: -this-unit-id template-haskell + + -- This should match the default-extensions used in 'ghc.cabal'. This way, + -- GHCi can be used to load it along with the compiler. + Default-Extensions: + NoImplicitPrelude -- cgit v1.2.1