GHC 7.10 support

This commit is contained in:
Ben Gamari 2015-02-05 23:55:29 -05:00
parent a84934d33a
commit a8f21531c9
6 changed files with 59 additions and 25 deletions

View File

@ -48,12 +48,16 @@ data-files:
installation/run.sh
profile/profile.tar
flag binPkgDb
default: True
description: bin-package-db package needed (needed for GHC >= 7.10)
library
hs-source-dirs: src
default-language: Haskell2010
build-depends:
aeson >=0.6 && < 0.9,
base >=4.6 && < 4.8,
base >=4.6 && < 4.9,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal >=0.3,
@ -63,7 +67,7 @@ library
containers >=0.5,
directory -any,
filepath -any,
ghc ==7.6.* || == 7.8.*,
ghc >=7.6 || < 7.11,
ghc-parser >=0.1.4,
haskeline -any,
here ==1.2.*,
@ -93,6 +97,8 @@ library
uuid >=1.3,
vector -any,
ipython-kernel >=0.3
if flag(binPkgDb)
build-depends: bin-package-db
exposed-modules: IHaskell.Display
IHaskell.Convert
@ -125,7 +131,7 @@ executable IHaskell
-- Other library packages from which modules are imported.
default-language: Haskell2010
build-depends:
base >=4.6 && < 4.8,
base >=4.6 && < 4.9,
ghc-paths ==0.1.*,
aeson >=0.6 && < 0.9,
bytestring >=0.10,
@ -134,12 +140,14 @@ executable IHaskell
mono-traversable >=0.6,
containers >=0.5,
directory -any,
ghc ==7.6.* || == 7.8.*,
ghc >=7.6 && < 7.11,
ihaskell -any,
MissingH >=1.2,
text -any,
ipython-kernel >= 0.2,
unix >= 2.6
if flag(binPkgDb)
build-depends: bin-package-db
Test-Suite hspec
hs-source-dirs: src
@ -149,7 +157,7 @@ Test-Suite hspec
default-language: Haskell2010
build-depends:
aeson >=0.6 && < 0.9,
base >=4.6 && < 4.8,
base >=4.6 && < 4.9,
base64-bytestring >=1.0,
bytestring >=0.10,
cereal >=0.3,
@ -159,7 +167,7 @@ Test-Suite hspec
containers >=0.5,
directory -any,
filepath -any,
ghc ==7.6.* || == 7.8.*,
ghc >=7.6 && < 7.11,
ghc-parser >=0.1.1,
ghc-paths ==0.1.*,
haskeline -any,
@ -191,7 +199,8 @@ Test-Suite hspec
vector -any,
setenv ==0.1.*,
ipython-kernel >= 0.2
if flag(binPkgDb)
build-depends: bin-package-db
default-extensions:
DoAndIfThenElse

View File

@ -36,7 +36,7 @@ library
other-extensions: OverloadedStrings
hs-source-dirs: src
default-language: Haskell2010
build-depends: base >=4.6 && < 4.8,
build-depends: base >=4.6 && < 4.9,
aeson >=0.6 && < 0.9,
bytestring >=0.10,
cereal >=0.3,
@ -57,7 +57,7 @@ executable simple-calc-example
hs-source-dirs: examples
main-is: Calc.hs
build-depends: ipython-kernel,
base >=4.6 && <4.8,
base >=4.6 && <4.9,
filepath >=1.2,
mtl >=2.1,
parsec >=3.1,

View File

@ -1,4 +1,4 @@
{-# LANGUAGE OverloadedStrings, NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings, NoImplicitPrelude, FlexibleContexts #-}
module IHaskell.BrokenPackages (getBrokenPackages) where
import ClassyPrelude hiding ((<|>))

View File

@ -1,4 +1,5 @@
{-# LANGUAGE NoImplicitPrelude, OverloadedStrings, DoAndIfThenElse #-}
{-# LANGUAGE CPP, NoImplicitPrelude, OverloadedStrings, DoAndIfThenElse #-}
{-# LANGUAGE TypeFamilies, FlexibleContexts #-}
{- |
Description: Generates tab completion options.
@ -25,7 +26,10 @@ import Data.String.Utils (strip, startswith, endswith, replace)
import qualified Data.String.Utils as StringUtils
import System.Environment (getEnv)
import GHC
import GHC hiding (Qualified)
#if MIN_VERSION_ghc(7,10,0)
import GHC.PackageDb (ExposedModule(exposedName))
#endif
import DynFlags
import GhcMonad
import PackageConfig
@ -64,8 +68,12 @@ complete line pos = do
unqualNames = nub $ filter (not . isQualified) rdrNames
qualNames = nub $ scopeNames ++ filter isQualified rdrNames
#if !MIN_VERSION_ghc(7,10,0)
let exposedName = id
#endif
let Just db = pkgDatabase flags
getNames = map moduleNameString . exposedModules
getNames = map (moduleNameString . exposedName) . exposedModules
moduleNames = nub $ concatMap getNames db
let target = completionTarget line pos
@ -76,6 +84,12 @@ complete line pos = do
FilePath _ match -> match
otherwise -> intercalate "." target
#if MIN_VERSION_ghc(7,10,0)
let extName (FlagSpec {flagSpecName=name}) = name
#else
let extName (name, _, _) = name
#endif
options <-
case completion of
Empty -> return []
@ -100,9 +114,7 @@ complete line pos = do
-- Possibly leave out the fLangFlags? The
-- -XUndecidableInstances vs. obsolete
-- -fallow-undecidable-instances.
let extName (name, _, _) = name
kernelOptNames = concatMap getSetName kernelOpts
let kernelOptNames = concatMap getSetName kernelOpts
otherNames = ["-package","-Wall","-w"]
fNames = map extName fFlags ++
@ -120,8 +132,7 @@ complete line pos = do
return $ filter (ext `isPrefixOf`) allNames
Extension ext -> do
let extName (name, _, _) = name
xNames = map extName xFlags
let xNames = map extName xFlags
xNoNames = map ("No" ++) xNames
return $ filter (ext `isPrefixOf`) $ xNames ++ xNoNames

View File

@ -22,7 +22,10 @@ import Data.Typeable
import qualified Data.Serialize as Serialize
import System.Directory
import Filesystem.Path.CurrentOS (encodeString)
import System.Posix.IO
#if !MIN_VERSION_base(4,8,0)
import System.Posix.IO (createPipe)
#endif
import System.Posix.IO (fdToHandle)
import System.IO (hGetChar, hFlush)
import System.Random (getStdGen, randomRs)
import Unsafe.Coerce
@ -53,7 +56,7 @@ import GHC hiding (Stmt, TypeSig)
import Exception hiding (evaluate)
import Outputable hiding ((<>))
import Packages
import Module
import Module hiding (Module)
import qualified Pretty
import FastString
import Bag
@ -157,6 +160,9 @@ initializeImports = do
displayPackages <- liftIO $ do
(dflags, _) <- initPackages dflags
let Just db = pkgDatabase dflags
#if MIN_VERSION_ghc(7,10,0)
packageIdString = packageKeyPackageIdString dflags
#endif
packageNames = map (packageIdString . packageConfigId) db
initStr = "ihaskell-"
@ -566,9 +572,13 @@ evalCommand publish (Directive ShellCmd ('!':cmd)) state = wrapExecution state $
else
return $ displayError $ printf "No such directory: '%s'" directory
cmd -> liftIO $ do
#if MIN_VERSION_base(4,8,0)
(pipe, handle) <- createPipe
#else
(readEnd, writeEnd) <- createPipe
handle <- fdToHandle writeEnd
pipe <- fdToHandle readEnd
#endif
let initProcSpec = shell $ unwords cmd
procSpec = initProcSpec {
std_in = Inherit,

View File

@ -59,21 +59,25 @@ extensionFlag :: String -- Extension name, such as @"DataKinds"@
-> Maybe ExtFlag
extensionFlag ext =
case find (flagMatches ext) xFlags of
Just (_, flag, _) -> Just $ SetFlag flag
Just fs -> Just $ SetFlag $ flagSpecFlag fs
-- If it doesn't match an extension name, try matching against
-- disabling an extension.
Nothing ->
case find (flagMatchesNo ext) xFlags of
Just (_, flag, _) -> Just $ UnsetFlag flag
Just fs -> Just $ UnsetFlag $ flagSpecFlag fs
Nothing -> Nothing
where
-- Check if a FlagSpec matches an extension name.
flagMatches ext (name, _, _) = ext == name
flagMatches ext fs = ext == flagSpecName fs
-- Check if a FlagSpec matches "No<ExtensionName>".
-- In that case, we disable the extension.
flagMatchesNo ext (name, _, _) = ext == "No" ++ name
flagMatchesNo ext fs = ext == "No" ++ flagSpecName fs
#if !MIN_VERSION_ghc(7,10,0)
flagSpecName (name,_,_) = name
flagSpecFlag (_,flag,_) = flag
#endif
-- | Set an extension and update flags.
-- Return @Nothing@ on success. On failure, return an error message.