Commit 18e10881 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo

Drop support for GHC < 8.0

parent 6919aa67
...@@ -7,12 +7,10 @@ module IHaskellPrelude ( ...@@ -7,12 +7,10 @@ module IHaskellPrelude (
Data.Typeable.Typeable, Data.Typeable.Typeable,
Data.Typeable.cast, Data.Typeable.cast,
#if MIN_VERSION_ghc(7,8,0)
Data.Typeable.Proxy, Data.Typeable.Proxy,
GHC.Exts.IsString, GHC.Exts.IsString,
GHC.Exts.IsList, GHC.Exts.IsList,
#endif
System.IO.hPutStrLn, System.IO.hPutStrLn,
System.IO.hPutStr, System.IO.hPutStr,
...@@ -53,7 +51,7 @@ module IHaskellPrelude ( ...@@ -53,7 +51,7 @@ module IHaskellPrelude (
Data.IORef.modifyIORef', Data.IORef.modifyIORef',
Data.IORef.newIORef, Data.IORef.newIORef,
-- Miscellaneous names -- Miscellaneous names
Data.Map.Map, Data.Map.Map,
...@@ -78,13 +76,7 @@ import GHC.Enum as X ...@@ -78,13 +76,7 @@ import GHC.Enum as X
import GHC.Num as X import GHC.Num as X
import GHC.Real as X import GHC.Real as X
import GHC.Err as X hiding (absentErr) import GHC.Err as X hiding (absentErr)
#if MIN_VERSION_ghc(8,0,0)
import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>), Module(..)) import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>), Module(..))
#elif MIN_VERSION_ghc(7,10,0)
import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>))
#else
import GHC.Base as X hiding (Any)
#endif
import Data.List as X hiding (head, last, tail, init, transpose, subsequences, permutations, import Data.List as X hiding (head, last, tail, init, transpose, subsequences, permutations,
foldl, foldl1, maximum, minimum, scanl, scanl1, scanr, scanr1, foldl, foldl1, maximum, minimum, scanl, scanl1, scanr, scanr1,
span, break, mapAccumL, mapAccumR, dropWhileEnd, (!!), span, break, mapAccumL, mapAccumR, dropWhileEnd, (!!),
......
...@@ -22,9 +22,7 @@ import System.Process (readProcess, readProcessWithExitCode) ...@@ -22,9 +22,7 @@ import System.Process (readProcess, readProcessWithExitCode)
import System.Exit (exitSuccess, ExitCode(ExitSuccess)) import System.Exit (exitSuccess, ExitCode(ExitSuccess))
import Control.Exception (try, SomeException) import Control.Exception (try, SomeException)
import System.Environment (getArgs) import System.Environment (getArgs)
#if MIN_VERSION_ghc(7,8,0)
import System.Environment (setEnv) import System.Environment (setEnv)
#endif
import System.Posix.Signals import System.Posix.Signals
import qualified Data.Map as Map import qualified Data.Map as Map
import qualified Data.Text.Encoding as E import qualified Data.Text.Encoding as E
...@@ -142,12 +140,11 @@ runKernel kernelOpts profileSrc = do ...@@ -142,12 +140,11 @@ runKernel kernelOpts profileSrc = do
dir <- getIHaskellDir dir <- getIHaskellDir
Stdin.recordKernelProfile dir profile Stdin.recordKernelProfile dir profile
#if MIN_VERSION_ghc(7,8,0)
when useStack $ do when useStack $ do
-- Detect if we have stack -- Detect if we have stack
runResult <- try $ readProcessWithExitCode "stack" [] "" runResult <- try $ readProcessWithExitCode "stack" [] ""
let stack = let stack =
case runResult :: Either SomeException (ExitCode, String, String) of case runResult :: Either SomeException (ExitCode, String, String) of
Left _ -> False Left _ -> False
Right (exitCode, stackStdout, _) -> exitCode == ExitSuccess && "The Haskell Tool Stack" `isInfixOf` stackStdout Right (exitCode, stackStdout, _) -> exitCode == ExitSuccess && "The Haskell Tool Stack" `isInfixOf` stackStdout
...@@ -160,7 +157,6 @@ runKernel kernelOpts profileSrc = do ...@@ -160,7 +157,6 @@ runKernel kernelOpts profileSrc = do
in case tailMay val of in case tailMay val of
Nothing -> return () Nothing -> return ()
Just val' -> setEnv var val' Just val' -> setEnv var val'
#endif
-- Serve on all sockets and ports defined in the profile. -- Serve on all sockets and ports defined in the profile.
interface <- serveProfile profile debug interface <- serveProfile profile debug
...@@ -258,7 +254,7 @@ replyTo :: ZeroMQInterface -> Message -> MessageHeader -> KernelState -> Interpr ...@@ -258,7 +254,7 @@ replyTo :: ZeroMQInterface -> Message -> MessageHeader -> KernelState -> Interpr
replyTo interface KernelInfoRequest{} replyHeader state = do replyTo interface KernelInfoRequest{} replyHeader state = do
let send msg = liftIO $ writeChan (iopubChannel interface) msg let send msg = liftIO $ writeChan (iopubChannel interface) msg
-- Notify the frontend that the Kernel is idle -- Notify the frontend that the Kernel is idle
idleHeader <- liftIO $ dupHeader replyHeader StatusMessage idleHeader <- liftIO $ dupHeader replyHeader StatusMessage
send $ PublishStatus idleHeader Idle send $ PublishStatus idleHeader Idle
......
...@@ -31,7 +31,7 @@ import System.Environment (getEnv) ...@@ -31,7 +31,7 @@ import System.Environment (getEnv)
import GHC hiding (Qualified) import GHC hiding (Qualified)
#if MIN_VERSION_ghc(8,2,0) #if MIN_VERSION_ghc(8,2,0)
import GHC.PackageDb import GHC.PackageDb
#elif MIN_VERSION_ghc(7,10,0) #else
import GHC.PackageDb (ExposedModule(exposedName)) import GHC.PackageDb (ExposedModule(exposedName))
#endif #endif
import DynFlags import DynFlags
...@@ -63,16 +63,14 @@ data CompletionType = Empty ...@@ -63,16 +63,14 @@ data CompletionType = Empty
| KernelOption String | KernelOption String
| Extension String | Extension String
deriving (Show, Eq) deriving (Show, Eq)
#if MIN_VERSION_ghc(8,2,0) #if MIN_VERSION_ghc(8,2,0)
exposedName :: (a, b) -> a
exposedName = fst exposedName = fst
#endif #endif
#if MIN_VERSION_ghc(7,10,0)
extName (FlagSpec { flagSpecName = name }) = name extName (FlagSpec { flagSpecName = name }) = name
#else
extName (name, _, _) = name
exposedName = id
#endif
complete :: String -> Int -> Interpreter (String, [String]) complete :: String -> Int -> Interpreter (String, [String])
complete code posOffset = do complete code posOffset = do
-- Get the line of code which is being completed and offset within that line -- Get the line of code which is being completed and offset within that line
...@@ -93,11 +91,7 @@ complete code posOffset = do ...@@ -93,11 +91,7 @@ complete code posOffset = do
let Just db = pkgDatabase flags let Just db = pkgDatabase flags
getNames = map (moduleNameString . exposedName) . exposedModules getNames = map (moduleNameString . exposedName) . exposedModules
#if MIN_VERSION_ghc(8,0,0)
moduleNames = nub $ concatMap getNames $ concatMap snd db moduleNames = nub $ concatMap getNames $ concatMap snd db
#else
moduleNames = nub $ concatMap getNames db
#endif
let target = completionTarget line pos let target = completionTarget line pos
completion = completionType line pos target completion = completionType line pos target
...@@ -127,17 +121,12 @@ complete code posOffset = do ...@@ -127,17 +121,12 @@ complete code posOffset = do
return $ filter (prefix `isPrefixOf`) moduleNames return $ filter (prefix `isPrefixOf`) moduleNames
DynFlag ext -> do DynFlag ext -> do
-- Possibly leave out the fLangFlags? The -XUndecidableInstances vs. obsolete -- Possibly leave out the fLangFlags?
-- -fallow-undecidable-instances.
let kernelOptNames = concatMap getSetName kernelOpts let kernelOptNames = concatMap getSetName kernelOpts
otherNames = ["-package", "-Wall", "-w"] otherNames = ["-package", "-Wall", "-w"]
fNames = map extName fFlags ++ fNames = map extName fFlags ++
#if MIN_VERSION_ghc(8,0,0)
map extName wWarningFlags ++ map extName wWarningFlags ++
#else
map extName fWarningFlags ++
#endif
map extName fLangFlags map extName fLangFlags
fNoNames = map ("no" ++) fNames fNoNames = map ("no" ++) fNames
fAllNames = map ("-f" ++) (fNames ++ fNoNames) fAllNames = map ("-f" ++) (fNames ++ fNoNames)
...@@ -269,7 +258,7 @@ completionTarget code cursor = expandCompletionPiece pieceToComplete ...@@ -269,7 +258,7 @@ completionTarget code cursor = expandCompletionPiece pieceToComplete
pieceToComplete = map fst <$> find (elem cursor . map snd) pieces pieceToComplete = map fst <$> find (elem cursor . map snd) pieces
pieces = splitAlongCursor $ Split.split splitter $ zip code [1 ..] pieces = splitAlongCursor $ Split.split splitter $ zip code [1 ..]
splitter = Split.defaultSplitter splitter = Split.defaultSplitter
{ {
-- Split using only the characters, which are the first elements of the (char, index) tuple -- Split using only the characters, which are the first elements of the (char, index) tuple
Split.delimiter = Split.Delimiter [uncurry isDelim] Split.delimiter = Split.Delimiter [uncurry isDelim]
-- Condense multiple delimiters into one and then drop them. -- Condense multiple delimiters into one and then drop them.
......
...@@ -65,11 +65,7 @@ import qualified Linker ...@@ -65,11 +65,7 @@ import qualified Linker
import TcType import TcType
import Unify import Unify
import InstEnv import InstEnv
#if MIN_VERSION_ghc(7, 8, 0)
import GhcMonad (liftIO, withSession) import GhcMonad (liftIO, withSession)
#else
import GhcMonad (withSession)
#endif
import GHC hiding (Stmt, TypeSig) import GHC hiding (Stmt, TypeSig)
import Exception hiding (evaluate) import Exception hiding (evaluate)
import Outputable hiding ((<>)) import Outputable hiding ((<>))
...@@ -126,12 +122,7 @@ write :: (MonadIO m, GhcMonad m) => KernelState -> String -> m () ...@@ -126,12 +122,7 @@ write :: (MonadIO m, GhcMonad m) => KernelState -> String -> m ()
write state x = when (kernelDebug state) $ liftIO $ hPutStrLn stderr $ "DEBUG: " ++ x write state x = when (kernelDebug state) $ liftIO $ hPutStrLn stderr $ "DEBUG: " ++ x
type Interpreter = Ghc type Interpreter = Ghc
#if MIN_VERSION_ghc(7, 8, 0)
-- GHC 7.8 exports a MonadIO instance for Ghc
#else
instance MonadIO.MonadIO Interpreter where
liftIO = MonadUtils.liftIO
#endif
requiredGlobalImports :: [String] requiredGlobalImports :: [String]
requiredGlobalImports = requiredGlobalImports =
[ "import qualified Prelude as IHaskellPrelude" [ "import qualified Prelude as IHaskellPrelude"
...@@ -194,23 +185,13 @@ packageIdString' dflags pkg_cfg = ...@@ -194,23 +185,13 @@ packageIdString' dflags pkg_cfg =
Just cfg -> let Just cfg -> let
PackageName name = packageName cfg PackageName name = packageName cfg
in unpackFS name in unpackFS name
#elif MIN_VERSION_ghc(8,0,0)
fromMaybe "(unknown)" (unitIdPackageIdString dflags $ packageConfigId pkg_cfg)
#elif MIN_VERSION_ghc(7,10,2)
fromMaybe "(unknown)" (packageKeyPackageIdString dflags $ packageConfigId pkg_cfg)
#elif MIN_VERSION_ghc(7,10,0)
packageKeyPackageIdString dflags . packageConfigId
#else #else
packageIdString . packageConfigId fromMaybe "(unknown)" (unitIdPackageIdString dflags $ packageConfigId pkg_cfg)
#endif #endif
getPackageConfigs :: DynFlags -> [PackageConfig] getPackageConfigs :: DynFlags -> [PackageConfig]
getPackageConfigs dflags = getPackageConfigs dflags =
#if MIN_VERSION_ghc(8,0,0)
foldMap snd pkgDb foldMap snd pkgDb
#else
pkgDb
#endif
where where
Just pkgDb = pkgDatabase dflags Just pkgDb = pkgDatabase dflags
...@@ -236,10 +217,6 @@ initializeImports = do ...@@ -236,10 +217,6 @@ initializeImports = do
iHaskellPkgName = initStr ++ intercalate "." (map show (versionBranch version)) iHaskellPkgName = initStr ++ intercalate "." (map show (versionBranch version))
#endif #endif
#if !MIN_VERSION_ghc(8,0,0)
unitId = packageId
#endif
dependsOnRight pkg = not $ null $ do dependsOnRight pkg = not $ null $ do
pkg <- db pkg <- db
depId <- depends pkg depId <- depends pkg
...@@ -449,11 +426,7 @@ flushWidgetMessages state evalMsgs widgetHandler = do ...@@ -449,11 +426,7 @@ flushWidgetMessages state evalMsgs widgetHandler = do
getErrMsgDoc :: ErrUtils.ErrMsg -> SDoc getErrMsgDoc :: ErrUtils.ErrMsg -> SDoc
#if MIN_VERSION_ghc(8,0,0)
getErrMsgDoc = ErrUtils.pprLocErrMsg getErrMsgDoc = ErrUtils.pprLocErrMsg
#else
getErrMsgDoc msg = ErrUtils.errMsgShortString msg $$ ErrUtils.errMsgContext msg
#endif
safely :: KernelState -> Interpreter EvalOut -> Interpreter EvalOut safely :: KernelState -> Interpreter EvalOut -> Interpreter EvalOut
safely state = ghandle handler . ghandle sourceErrorHandler safely state = ghandle handler . ghandle sourceErrorHandler
...@@ -1083,11 +1056,7 @@ doLoadModule name modName = do ...@@ -1083,11 +1056,7 @@ doLoadModule name modName = do
setSessionDynFlags $ flip gopt_set Opt_BuildDynamicToo setSessionDynFlags $ flip gopt_set Opt_BuildDynamicToo
flags flags
{ hscTarget = objTarget flags { hscTarget = objTarget flags
#if MIN_VERSION_ghc(8,0,0)
, log_action = \dflags sev srcspan ppr _style msg -> modifyIORef' errRef (showSDoc flags msg :) , log_action = \dflags sev srcspan ppr _style msg -> modifyIORef' errRef (showSDoc flags msg :)
#else
, log_action = \dflags sev srcspan ppr msg -> modifyIORef' errRef (showSDoc flags msg :)
#endif
} }
-- Load the new target. -- Load the new target.
...@@ -1138,11 +1107,9 @@ doLoadModule name modName = do ...@@ -1138,11 +1107,9 @@ doLoadModule name modName = do
initializeItVariable initializeItVariable
return $ displayError $ "Failed to load module " ++ modName ++ ": " ++ show exception return $ displayError $ "Failed to load module " ++ modName ++ ": " ++ show exception
#if MIN_VERSION_ghc(7,8,0)
objTarget flags = defaultObjectTarget $ targetPlatform flags objTarget flags = defaultObjectTarget $ targetPlatform flags
#else
objTarget flags = defaultObjectTarget
#endif
keepingItVariable :: Interpreter a -> Interpreter a keepingItVariable :: Interpreter a -> Interpreter a
keepingItVariable act = do keepingItVariable act = do
-- Generate the it variable temp name -- Generate the it variable temp name
...@@ -1217,7 +1184,6 @@ capturedEval output stmt = do ...@@ -1217,7 +1184,6 @@ capturedEval output stmt = do
-- Initialize evaluation context. -- Initialize evaluation context.
results <- forM initStmts goStmt results <- forM initStmts goStmt
#if __GLASGOW_HASKELL__ >= 800
-- This works fine on GHC 8.0 and newer -- This works fine on GHC 8.0 and newer
dyn <- dynCompileExpr readVariable dyn <- dynCompileExpr readVariable
pipe <- case fromDynamic dyn of pipe <- case fromDynamic dyn of
...@@ -1226,26 +1192,7 @@ capturedEval output stmt = do ...@@ -1226,26 +1192,7 @@ capturedEval output stmt = do
handle <- fdToHandle fd handle <- fdToHandle fd
hSetEncoding handle utf8 hSetEncoding handle utf8
return handle return handle
#else
-- Get the pipe to read printed output from. This is effectively the source code of dynCompileExpr
-- from GHC API's InteractiveEval. However, instead of using a `Dynamic` as an intermediary, it just
-- directly reads the value. This is incredibly unsafe! However, for some reason the `getContext`
-- and `setContext` required by dynCompileExpr (to import and clear Data.Dynamic) cause issues with
-- data declarations being updated (e.g. it drops newer versions of data declarations for older ones
-- for unknown reasons). First, compile down to an HValue.
let pipeExpr = printf "let %s = %s" (var "pipe_var_") readVariable
Just (_, hValues, _) <- withSession $ liftIO . flip hscStmt pipeExpr
-- Then convert the HValue into an executable bit, and read the value.
pipe <- liftIO $ do
fds <- unsafeCoerce hValues
fd <- case fds of
fd : _ -> return fd
[] -> fail "Failed to evaluate pipes"
_ -> fail $ "Expected one fd, saw "++show (length fds)
handle <- fdToHandle fd
hSetEncoding handle utf8
return handle
#endif
-- Keep track of whether execution has completed. -- Keep track of whether execution has completed.
completed <- liftIO $ newMVar False completed <- liftIO $ newMVar False
finishedReading <- liftIO newEmptyMVar finishedReading <- liftIO newEmptyMVar
......
...@@ -91,11 +91,7 @@ extensionFlag ext = ...@@ -91,11 +91,7 @@ extensionFlag ext =
-- Check if a FlagSpec matches "No<ExtensionName>". In that case, we disable the extension. -- Check if a FlagSpec matches "No<ExtensionName>". In that case, we disable the extension.
flagMatchesNo ext fs = ext == "No" ++ flagSpecName fs flagMatchesNo ext fs = ext == "No" ++ flagSpecName fs
#if !MIN_VERSION_ghc(7,10,0)
flagSpecName (name, _, _) = name
flagSpecFlag (_, flag, _) = flag
#endif
-- | Pretty-print dynamic flags (taken from 'InteractiveUI' module of `ghc-bin`) -- | Pretty-print dynamic flags (taken from 'InteractiveUI' module of `ghc-bin`)
pprDynFlags :: Bool -- ^ Whether to include flags which are on by default pprDynFlags :: Bool -- ^ Whether to include flags which are on by default
-> DynFlags -> DynFlags
...@@ -111,17 +107,10 @@ pprDynFlags show_all dflags = ...@@ -111,17 +107,10 @@ pprDynFlags show_all dflags =
] ]
where where
#if MIN_VERSION_ghc(8,0,0)
warningFlags = DynFlags.wWarningFlags warningFlags = DynFlags.wWarningFlags
#else
warningFlags = DynFlags.fWarningFlags
#endif
#if MIN_VERSION_ghc(7,8,0)
opt = gopt opt = gopt
#else
opt = dopt
#endif
setting test flag setting test flag
| quiet = O.empty :: O.SDoc | quiet = O.empty :: O.SDoc
| is_on = fstr name :: O.SDoc | is_on = fstr name :: O.SDoc
...@@ -131,7 +120,7 @@ pprDynFlags show_all dflags = ...@@ -131,7 +120,7 @@ pprDynFlags show_all dflags =
f = flagSpecFlag flag f = flagSpecFlag flag
is_on = test f dflags is_on = test f dflags
quiet = not show_all && test f default_dflags == is_on quiet = not show_all && test f default_dflags == is_on
#if MIN_VERSION_ghc(8,6,0) #if MIN_VERSION_ghc(8,6,0)
default_dflags = defaultDynFlags (settings dflags) (llvmTargets dflags, llvmPasses dflags) default_dflags = defaultDynFlags (settings dflags) (llvmTargets dflags, llvmPasses dflags)
#elif MIN_VERSION_ghc(8,4,0) #elif MIN_VERSION_ghc(8,4,0)
...@@ -139,22 +128,19 @@ pprDynFlags show_all dflags = ...@@ -139,22 +128,19 @@ pprDynFlags show_all dflags =
#else #else
default_dflags = defaultDynFlags (settings dflags) default_dflags = defaultDynFlags (settings dflags)
#endif #endif
fstr, fnostr :: String -> O.SDoc fstr, fnostr :: String -> O.SDoc
fstr str = O.text "-f" O.<> O.text str fstr str = O.text "-f" O.<> O.text str
fnostr str = O.text "-fno-" O.<> O.text str fnostr str = O.text "-fno-" O.<> O.text str
(ghciFlags, others) = partition (\f -> flagSpecFlag f `elem` flgs) DynFlags.fFlags (ghciFlags, others) = partition (\f -> flagSpecFlag f `elem` flgs) DynFlags.fFlags
flgs = concat [flgs1, flgs2, flgs3] flgs = concat [flgs1, flgs2, flgs3]
flgs1 = [Opt_PrintExplicitForalls] flgs1 = [Opt_PrintExplicitForalls]
#if MIN_VERSION_ghc(7,8,0)
flgs2 = [Opt_PrintExplicitKinds] flgs2 = [Opt_PrintExplicitKinds]
#else
flgs2 = []
#endif
flgs3 = [Opt_PrintBindResult, Opt_BreakOnException, Opt_BreakOnError, Opt_PrintEvldWithShow] flgs3 = [Opt_PrintBindResult, Opt_BreakOnException, Opt_BreakOnError, Opt_PrintEvldWithShow]
-- | Pretty-print the base language and active options (taken from `InteractiveUI` module of -- | Pretty-print the base language and active options (taken from `InteractiveUI` module of
...@@ -386,7 +372,7 @@ evalDeclarations decl = do ...@@ -386,7 +372,7 @@ evalDeclarations decl = do
cleanUpDuplicateInstances :: GhcMonad m => m () cleanUpDuplicateInstances :: GhcMonad m => m ()
cleanUpDuplicateInstances = modifySession $ \hscEnv -> cleanUpDuplicateInstances = modifySession $ \hscEnv ->
let let
-- Get all class instances -- Get all class instances
ic = hsc_IC hscEnv ic = hsc_IC hscEnv
(clsInsts, famInsts) = ic_instances ic (clsInsts, famInsts) = ic_instances ic
...@@ -395,21 +381,11 @@ cleanUpDuplicateInstances = modifySession $ \hscEnv -> ...@@ -395,21 +381,11 @@ cleanUpDuplicateInstances = modifySession $ \hscEnv ->
in hscEnv { hsc_IC = ic { ic_instances = (clsInsts', famInsts) } } in hscEnv { hsc_IC = ic { ic_instances = (clsInsts', famInsts) } }
where where
instEq :: ClsInst -> ClsInst -> Bool instEq :: ClsInst -> ClsInst -> Bool
#if MIN_VERSION_ghc(8,0,0)
-- Only support replacing instances on GHC 7.8 and up -- Only support replacing instances on GHC 7.8 and up
instEq c1 c2 instEq c1 c2
| ClsInst { is_tvs = tpl_tvs, is_tys = tpl_tys, is_cls = cls } <- c1, | ClsInst { is_tvs = tpl_tvs, is_tys = tpl_tys, is_cls = cls } <- c1,
ClsInst { is_tys = tpl_tys', is_cls = cls' } <- c2 ClsInst { is_tys = tpl_tys', is_cls = cls' } <- c2
= cls == cls' && isJust (tcMatchTys tpl_tys tpl_tys') = cls == cls' && isJust (tcMatchTys tpl_tys tpl_tys')
#elif MIN_VERSION_ghc(7,8,0)
instEq c1 c2
| ClsInst { is_tvs = tpl_tvs, is_tys = tpl_tys, is_cls = cls } <- c1,
ClsInst { is_tys = tpl_tys', is_cls = cls' } <- c2
= let tpl_tv_set = mkVarSet tpl_tvs
in cls == cls' && isJust (tcMatchTys tpl_tv_set tpl_tys tpl_tys')
#else
instEq _ _ = False
#endif
-- | Get the type of an expression and convert it to a string. -- | Get the type of an expression and convert it to a string.
...@@ -450,18 +426,12 @@ getDescription str = do ...@@ -450,18 +426,12 @@ getDescription str = do
where where
#if MIN_VERSION_ghc(7,8,0)
getInfo' = getInfo False getInfo' = getInfo False
#else
getInfo' = getInfo
#endif
#if MIN_VERSION_ghc(8,4,0) #if MIN_VERSION_ghc(8,4,0)
getType (theType, _, _, _, _) = theType getType (theType, _, _, _, _) = theType
#elif MIN_VERSION_ghc(7,8,0)
getType (theType, _, _, _) = theType
#else #else
getType (theType, _, _) = theType getType (theType, _, _, _) = theType
#endif #endif
#if MIN_VERSION_ghc(8,4,0) #if MIN_VERSION_ghc(8,4,0)
...@@ -470,16 +440,12 @@ getDescription str = do ...@@ -470,16 +440,12 @@ getDescription str = do
showFixity thing fixity O.$$ showFixity thing fixity O.$$
O.vcat (map GHC.pprInstance classInstances) O.$$ O.vcat (map GHC.pprInstance classInstances) O.$$
O.vcat (map GHC.pprFamInst famInstances) O.vcat (map GHC.pprFamInst famInstances)
#elif MIN_VERSION_ghc(7,8,0) #else
printInfo (thing, fixity, classInstances, famInstances) = printInfo (thing, fixity, classInstances, famInstances) =
pprTyThingInContextLoc thing O.$$ pprTyThingInContextLoc thing O.$$
showFixity thing fixity O.$$ showFixity thing fixity O.$$
O.vcat (map GHC.pprInstance classInstances) O.$$ O.vcat (map GHC.pprInstance classInstances) O.$$
O.vcat (map GHC.pprFamInst famInstances) O.vcat (map GHC.pprFamInst famInstances)
#else
printInfo (thing, fixity, classInstances) =
pprTyThingInContextLoc False thing O.$$ showFixity thing fixity O.$$
O.vcat (map GHC.pprInstance classInstances)
#endif #endif
showFixity thing fixity = showFixity thing fixity =
if fixity == GHC.defaultFixity if fixity == GHC.defaultFixity
......
...@@ -8,12 +8,10 @@ module IHaskellPrelude ( ...@@ -8,12 +8,10 @@ module IHaskellPrelude (
Data.Typeable.Typeable, Data.Typeable.Typeable,
Data.Typeable.cast, Data.Typeable.cast,
#if MIN_VERSION_ghc(7,8,0)
Data.Typeable.Proxy, Data.Typeable.Proxy,
GHC.Exts.IsString, GHC.Exts.IsString,
GHC.Exts.IsList, GHC.Exts.IsList,
#endif
System.IO.hPutStrLn, System.IO.hPutStrLn,
System.IO.hPutStr, System.IO.hPutStr,
...@@ -54,7 +52,7 @@ module IHaskellPrelude ( ...@@ -54,7 +52,7 @@ module IHaskellPrelude (
Data.IORef.modifyIORef', Data.IORef.modifyIORef',
Data.IORef.newIORef, Data.IORef.newIORef,
-- Miscellaneous names -- Miscellaneous names
Data.Map.Map, Data.Map.Map,
...@@ -80,13 +78,7 @@ import GHC.Enum as X ...@@ -80,13 +78,7 @@ import GHC.Enum as X
import GHC.Num as X import GHC.Num as X
import GHC.Real as X import GHC.Real as X
import GHC.Err as X hiding (absentErr) import GHC.Err as X hiding (absentErr)
#if MIN_VERSION_ghc(8,0,0)
import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>), Module(..)) import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>), Module(..))
#elif MIN_VERSION_ghc(7,10,0)
import GHC.Base as X hiding (Any, mapM, foldr, sequence, many, (<|>))
#else
import GHC.Base as X hiding (Any)
#endif
import Data.List as X hiding (head, last, tail, init, transpose, subsequences, permutations, import Data.List as X hiding (head, last, tail, init, transpose, subsequences, permutations,
foldl, foldl1, maximum, minimum, scanl, scanl1, scanr, scanr1, foldl, foldl1, maximum, minimum, scanl, scanl1, scanr, scanr1,
span, break, mapAccumL, mapAccumR, dropWhileEnd, (!!), span, break, mapAccumL, mapAccumR, dropWhileEnd, (!!),
......
...@@ -89,14 +89,7 @@ pages string expected = evaluationComparing comparison string ...@@ -89,14 +89,7 @@ pages string expected = evaluationComparing comparison string
Nothing -> dropScriptTag $ tail str Nothing -> dropScriptTag $ tail str
fixQuotes :: String -> String fixQuotes :: String -> String
#if MIN_VERSION_ghc(7, 8, 0)
fixQuotes = id fixQuotes = id
#else
fixQuotes = map $ \char -> case char of
'\8216' -> '`'
'\8217' -> '\''
c -> c
#endif
testEval :: Spec testEval :: Spec
......
{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE CPP #-} {-# LANGUAGE CPP #-}
module IHaskell.Test.Parser (testParser) where module IHaskell.Test.Parser (testParser) where
import Prelude import Prelude
...@@ -234,10 +234,4 @@ testParseString = describe "Parser" $ do ...@@ -234,10 +234,4 @@ testParseString = describe "Parser" $ do
|]) >>= (`shouldBe` [Located 2 (Expression "first"), Located 4 (Expression "second")]) |]) >>= (`shouldBe` [Located 2 (Expression "first"), Located 4 (Expression "second")])
where where
dataKindsError = ParseError (Loc 1 10) msg dataKindsError = ParseError (Loc 1 10) msg
#if MIN_VERSION_ghc(7, 10, 0)
msg = "Cannot parse data constructor in a data/newtype declaration: 3" msg = "Cannot parse data constructor in a data/newtype declaration: 3"
#elif MIN_VERSION_ghc(7, 8, 0)
msg = "Illegal literal in type (use DataKinds to enable): 3"
#else
msg = "Illegal literal in type (use -XDataKinds to enable): 3"
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment