diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2015-12-15 23:57:46 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-12-15 23:59:54 +0100 |
commit | c1e25536d67fba33ad6ddae5556115340d99000a (patch) | |
tree | 4aa98e5fd9faa46df67412f94fef33d52205181e /ghc | |
parent | 28638dfe79e915f33d75a1b22c5adce9e2b62b97 (diff) | |
download | haskell-c1e25536d67fba33ad6ddae5556115340d99000a.tar.gz |
Expose enabled language extensions to TH
This exposes `template-haskell` functions for querying the language
extensions which are enabled when compiling a module,
- an `isExtEnabled` function to check whether an extension is enabled
- an `extsEnabled` function to obtain a full list of enabled extensions
To avoid code duplication this adds a `GHC.LanguageExtensions` module to
`ghc-boot` and moves `DynFlags.ExtensionFlag` into it. A happy
consequence of this is that the ungainly `DynFlags` lost around 500
lines. Moreover, flags corresponding to language extensions are now
clearly distinguished from other flags due to the `LangExt.*` prefix.
Updates haddock submodule.
This fixes #10820.
Test Plan: validate
Reviewers: austin, spinda, hvr, goldfire, alanz
Reviewed By: goldfire
Subscribers: mpickering, RyanGlScott, hvr, simonpj, thomie
Differential Revision: https://phabricator.haskell.org/D1200
GHC Trac Issues: #10820
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/InteractiveUI.hs | 11 | ||||
-rw-r--r-- | ghc/ghc-bin.cabal.in | 1 |
2 files changed, 7 insertions, 5 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 0727d6b629..43c789b26e 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -62,6 +62,7 @@ import Maybes ( orElse, expectJust ) import NameSet import Panic hiding ( showException ) import Util +import qualified GHC.LanguageExtensions as LangExt -- Haskell Libraries import System.Console.Haskeline as Haskeline @@ -380,8 +381,8 @@ interactiveUI config srcs maybe_exprs = do -- as the global DynFlags, plus -XExtendedDefaultRules and -- -XNoMonomorphismRestriction. dflags <- getDynFlags - let dflags' = (`xopt_set` Opt_ExtendedDefaultRules) - . (`xopt_unset` Opt_MonomorphismRestriction) + let dflags' = (`xopt_set` LangExt.ExtendedDefaultRules) + . (`xopt_unset` LangExt.MonomorphismRestriction) $ dflags GHC.setInteractiveDynFlags dflags' @@ -859,7 +860,7 @@ checkInputForLayout :: String -> InputT GHCi (Maybe String) -> InputT GHCi (Maybe String) checkInputForLayout stmt getStmt = do dflags' <- getDynFlags - let dflags = xopt_set dflags' Opt_AlternativeLayoutRule + let dflags = xopt_set dflags' LangExt.AlternativeLayoutRule st0 <- getGHCiState let buf' = stringToStringBuffer stmt loc = mkRealSrcLoc (fsLit (progname st0)) (line_number st0) 1 @@ -1962,7 +1963,7 @@ setGHCContextFromGHCiState = do iidecls <- filterM (tryBool.checkAdd) (transient_ctx st ++ remembered_ctx st) dflags <- GHC.getSessionDynFlags GHC.setContext $ - if xopt Opt_ImplicitPrelude dflags && not (any isPreludeImport iidecls) + if xopt LangExt.ImplicitPrelude dflags && not (any isPreludeImport iidecls) then iidecls ++ [implicitPreludeImport] else iidecls -- XXX put prel at the end, so that guessCurrentModule doesn't pick it up. @@ -2371,7 +2372,7 @@ showImports = do prel_imp | any isPreludeImport (rem_ctx ++ trans_ctx) = [] - | not (xopt Opt_ImplicitPrelude dflags) = [] + | not (xopt LangExt.ImplicitPrelude dflags) = [] | otherwise = ["import Prelude -- implicit"] trans_comment s = s ++ " -- added automatically" diff --git a/ghc/ghc-bin.cabal.in b/ghc/ghc-bin.cabal.in index 4f67e479c7..90b8a55e5b 100644 --- a/ghc/ghc-bin.cabal.in +++ b/ghc/ghc-bin.cabal.in @@ -33,6 +33,7 @@ Executable ghc directory >= 1 && < 1.3, process >= 1 && < 1.5, filepath >= 1 && < 1.5, + ghc-boot, ghc if os(windows) Build-Depends: Win32 |