commit c7d5e1322f54b5387767c15788d8372705b8981b Author: Sergei Trofimovich Date: Sun Oct 3 22:32:12 2010 +0300 Sat Jul 31 14:55:06 EEST 2010 Ian Lynagh * Expose the functions haddock needs even when haddock is disabled; #3558 --- compiler/main/GHC.hs | 13 +++++++++++-- compiler/main/InteractiveEval.hs | 9 --------- compiler/typecheck/TcRnDriver.lhs | 24 +++++++++++++++--------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs index be7d574..2f25cbe 100644 --- a/compiler/main/GHC.hs +++ b/compiler/main/GHC.hs @@ -111,13 +111,13 @@ module GHC ( showModule, isModuleInterpreted, InteractiveEval.compileExpr, HValue, dynCompileExpr, - lookupName, GHC.obtainTermFromId, GHC.obtainTermFromVal, reconstructType, modInfoModBreaks, ModBreaks(..), BreakIndex, BreakInfo(breakInfo_number, breakInfo_module), BreakArray, setBreakOn, setBreakOff, getBreak, #endif + lookupName, -- * Abstract syntax elements @@ -243,9 +243,9 @@ import Linker ( HValue ) import ByteCodeInstr import BreakArray import InteractiveEval -import TcRnDriver #endif +import TcRnDriver import TcIface import TcRnTypes hiding (LIE) import TcRnMonad ( initIfaceCheck ) @@ -2711,3 +2711,12 @@ obtainTermFromId bound force id = liftIO $ InteractiveEval.obtainTermFromId hsc_env bound force id #endif + +-- | Returns the 'TyThing' for a 'Name'. The 'Name' may refer to any +-- entity known to GHC, including 'Name's defined using 'runStmt'. +lookupName :: GhcMonad m => Name -> m (Maybe TyThing) +lookupName name = withSession $ \hsc_env -> do + mb_tything <- ioMsg $ tcRnLookupName hsc_env name + return mb_tything + -- XXX: calls panic in some circumstances; is that ok? + diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs index 352fbf0..3339313 100644 --- a/compiler/main/InteractiveEval.hs +++ b/compiler/main/InteractiveEval.hs @@ -29,7 +29,6 @@ module InteractiveEval ( showModule, isModuleInterpreted, compileExpr, dynCompileExpr, - lookupName, Term(..), obtainTermFromId, obtainTermFromVal, reconstructType, skolemiseSubst, skolemiseTy #endif @@ -922,14 +921,6 @@ parseName str = withSession $ \hsc_env -> do (L _ rdr_name) <- hscParseIdentifier (hsc_dflags hsc_env) str ioMsgMaybe $ tcRnLookupRdrName hsc_env rdr_name --- | Returns the 'TyThing' for a 'Name'. The 'Name' may refer to any --- entity known to GHC, including 'Name's defined using 'runStmt'. -lookupName :: GhcMonad m => Name -> m (Maybe TyThing) -lookupName name = withSession $ \hsc_env -> do - mb_tything <- ioMsg $ tcRnLookupName hsc_env name - return mb_tything - -- XXX: calls panic in some circumstances; is that ok? - -- ----------------------------------------------------------------------------- -- Getting the type of an expression diff --git a/compiler/typecheck/TcRnDriver.lhs b/compiler/typecheck/TcRnDriver.lhs index 323a167..342763d 100644 --- a/compiler/typecheck/TcRnDriver.lhs +++ b/compiler/typecheck/TcRnDriver.lhs @@ -9,10 +9,10 @@ module TcRnDriver ( #ifdef GHCI tcRnStmt, tcRnExpr, tcRnType, tcRnLookupRdrName, - tcRnLookupName, - tcRnGetInfo, getModuleExports, #endif + tcRnLookupName, + tcRnGetInfo, tcRnModule, tcTopSrcDecls, tcRnExtCore @@ -71,6 +71,7 @@ import Outputable import DataCon import Type import Class +import TcType import Data.List ( sortBy ) #ifdef GHCI @@ -83,7 +84,6 @@ import IfaceEnv import MkId import BasicTypes import TidyPgm ( globaliseAndTidyId ) -import TcType ( isUnitTy, isTauTy, tyClsNamesOfDFunHead ) import TysWiredIn ( unitTy, mkListTy ) #endif @@ -1015,7 +1015,6 @@ get two defns for 'main' in the interface file! %********************************************************* \begin{code} -#ifdef GHCI setInteractiveContext :: HscEnv -> InteractiveContext -> TcRn a -> TcRn a setInteractiveContext hsc_env icxt thing_inside = let -- Initialise the tcg_inst_env with instances from all home modules. @@ -1046,6 +1045,7 @@ setInteractiveContext hsc_env icxt thing_inside \begin{code} +#ifdef GHCI tcRnStmt :: HscEnv -> InteractiveContext -> LStmt RdrName @@ -1401,6 +1401,7 @@ lookup_rdr_name rdr_name = do { return good_names } +#endif tcRnLookupName :: HscEnv -> Name -> IO (Messages, Maybe TyThing) tcRnLookupName hsc_env name @@ -1421,8 +1422,8 @@ tcRnLookupName' name = do _ -> panic "tcRnLookupName'" tcRnGetInfo :: HscEnv - -> Name - -> IO (Messages, Maybe (TyThing, Fixity, [Instance])) + -> Name + -> IO (Messages, Maybe (TyThing, Fixity, [Instance])) -- Used to implement :info in GHCi -- @@ -1432,8 +1433,14 @@ tcRnGetInfo :: HscEnv -- *and* as a type or class constructor; -- hence the call to dataTcOccs, and we return up to two results tcRnGetInfo hsc_env name - = initTcPrintErrors hsc_env iNTERACTIVE $ - let ictxt = hsc_IC hsc_env in + = initTcPrintErrors hsc_env iNTERACTIVE $ + tcRnGetInfo' hsc_env name + +tcRnGetInfo' :: HscEnv + -> Name + -> TcRn (TyThing, Fixity, [Instance]) +tcRnGetInfo' hsc_env name + = let ictxt = hsc_IC hsc_env in setInteractiveContext hsc_env ictxt $ do -- Load the interface for all unqualified types and classes @@ -1482,7 +1489,6 @@ loadUnqualIfaces ictxt isTcOcc (nameOccName name), -- Types and classes only unQualOK gre ] -- In scope unqualified doc = ptext (sLit "Need interface for module whose export(s) are in scope unqualified") -#endif /* GHCI */ \end{code} %************************************************************************ commit 83d056a7e15e3253c446d896707d0b012f9cf8b3 Author: Sergei Trofimovich Date: Sun Oct 3 22:30:53 2010 +0300 Sat Jul 31 02:50:01 EEST 2010 Ian Lynagh * Always haddock by default Revert this patch: Matthias Kilian **20090920181319 Don't build haddock if HADDOC_DOCS = NO, and disable HADDOC_DOCS if GhcWithInterpreter = NO Haddock uses TcRnDriver.tcRnGetInfo, which is only available if GHCI is built. Set HADDOC_DOCS to NO if GhcWithInterpreter is NO, and disable the haddock build if HADDOC_DOCS = NO. --- ghc.mk | 2 -- mk/config.mk.in | 2 +- 2 files changed, 1 insertions(+), 3 deletions(-) diff --git a/ghc.mk b/ghc.mk index 9193f46..1b5d1f9 100644 --- a/ghc.mk +++ b/ghc.mk @@ -529,11 +529,9 @@ BUILD_DIRS += \ $(GHC_GENAPPLY_DIR) endif -ifneq "$(HADDOCK_DOCS)" "NO" BUILD_DIRS += \ utils/haddock \ utils/haddock/doc -endif ifneq "$(CLEANING)" "YES" BUILD_DIRS += \ diff --git a/mk/config.mk.in b/mk/config.mk.in index 7399de0..55a9f19 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -736,7 +736,7 @@ SRC_ALEX_OPTS = -g HSTAGS = @HstagsCmd@ # Should we build haddock docs? -HADDOCK_DOCS = $(GhcWithInterpreter) +HADDOCK_DOCS = YES # And HsColour the sources? ifeq "$(HSCOLOUR)" "" HSCOLOUR_SRCS = NO