Skip to content

Commit

Permalink
WIP: Upgrade nightly to GHC 8.8.2
Browse files Browse the repository at this point in the history
Still need to modify the code base here to compile.

Fix all incompatibility after upgrading to GHC 8.8.2

Hide replaceExtension on path 0.7.0 or later

Fix deprecation error
  • Loading branch information
snoyberg authored and jeffhappily committed Mar 9, 2020
1 parent 9ae6c81 commit e0e7e28
Show file tree
Hide file tree
Showing 40 changed files with 142 additions and 73 deletions.
24 changes: 24 additions & 0 deletions snapshot-nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resolver: nightly-2020-02-04
name: snapshot-for-building-stack-with-ghc-8.8.2

packages:
- github: commercialhaskell/pantry
commit: 86462a97c4d8091993cc6e246fd0f2ae5aa608f0
- github: fpco/casa
commit: fc0ed26858bfc4f2966ed2dfb2871bae9266dda6
subdirs:
- casa-client
- casa-types
- github: snoyberg/filelock
commit: 97e83ecc133cd60a99df8e1fa5a3c2739ad007dc
- hackage-security-0.6.0.0@rev:0
- hpack-0.33.0@rev:0
- lukko-0.1.1.1@rev:0
- regex-applicative-text-0.1.0.1@rev:0

drop-packages:
# See https://github.com/commercialhaskell/stack/pull/4712
- cabal-install

# Force usage of Cabal that ships with GHC 8.8.2 to speed up builds
- Cabal
2 changes: 1 addition & 1 deletion src/Data/Attoparsec/Interpreter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import Data.List (intercalate)
import Data.Text (pack)
import Stack.Prelude
import System.FilePath (takeExtension)
import System.IO (stderr, hPutStrLn)
import System.IO (hPutStrLn)

-- | Parser to extract the stack command line embedded inside a comment
-- after validating the placement and formatting rules for a valid
Expand Down
41 changes: 41 additions & 0 deletions src/Path/Extended.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{-# LANGUAGE CPP #-}

module Path.Extended
( fileExtension
, addExtension
, replaceExtension
) where

import Control.Monad.Catch
import qualified Path
import Path (Path, File)

fileExtension :: MonadThrow m => Path b File -> m String
fileExtension =
#if MIN_VERSION_path(0,7,0)
Path.fileExtension
#else
pure . Path.fileExtension
#endif

addExtension :: MonadThrow m
=> String
-> Path b File
-> m (Path b File)
addExtension =
#if MIN_VERSION_path(0,7,0)
Path.addExtension
#else
Path.addFileExtension
#endif

replaceExtension :: MonadThrow m
=> String
-> Path b File
-> m (Path b File)
replaceExtension =
#if MIN_VERSION_path(0,7,0)
Path.replaceExtension
#else
flip (Path.-<.>)
#endif
1 change: 0 additions & 1 deletion src/Path/Extra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Path.Extra
,tryGetModificationTime
) where

import Data.Bool (bool)
import Data.Time (UTCTime)
import Path
import Path.IO
Expand Down
1 change: 0 additions & 1 deletion src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Data.Aeson (Value (Object, Array), (.=), object)
import qualified Data.HashMap.Strict as HM
import Data.List ((\\), isPrefixOf)
import Data.List.Extra (groupSort)
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NE
import qualified Data.Map as Map
import qualified Data.Set as Set
Expand Down
3 changes: 0 additions & 3 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,9 @@ import qualified Data.Map.Strict as Map
import Data.Monoid.Map (MonoidMap(..))
import qualified Data.Set as Set
import qualified Data.Text as T
import Data.Text.Encoding (encodeUtf8, decodeUtf8With)
import Data.Text.Encoding.Error (lenientDecode)
import qualified Distribution.Text as Cabal
import qualified Distribution.Version as Cabal
import Distribution.Types.BuildType (BuildType (Configure))
import Distribution.Types.PackageId (pkgVersion)
import Distribution.Types.PackageName (mkPackageName)
import Distribution.Version (mkVersion)
import Generics.Deriving.Monoid (memptydefault, mappenddefault)
Expand Down
5 changes: 2 additions & 3 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ import qualified Data.Conduit.List as CL
import Data.Conduit.Process.Typed (createSource)
import qualified Data.Conduit.Text as CT
import Data.List hiding (any)
import Data.List.NonEmpty (NonEmpty(..), nonEmpty)
import Data.List.NonEmpty (nonEmpty)
import qualified Data.List.NonEmpty as NonEmpty (toList)
import Data.List.Split (chunksOf)
import qualified Data.Map.Strict as M
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Data.Text as T
import Data.Text.Encoding (decodeUtf8, encodeUtf8)
import Data.Text.Encoding (decodeUtf8)
import Data.Tuple
import Data.Time (ZonedTime, getZonedTime, formatTime, defaultTimeLocale)
import qualified Data.ByteString.Char8 as S8
Expand Down Expand Up @@ -89,7 +89,6 @@ import qualified System.Directory as D
import System.Environment (getExecutablePath, lookupEnv)
import System.FileLock (withTryFileLock, SharedExclusive (Exclusive), withFileLock)
import qualified System.FilePath as FP
import System.IO (stderr, stdout)
import System.IO.Error (isDoesNotExistError)
import System.PosixCompat.Files (createLink, modificationTime, getFileStatus)
import System.PosixCompat.Time (epochTime)
Expand Down
1 change: 0 additions & 1 deletion src/Stack/BuildPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import Stack.Prelude hiding (Display (..))
import qualified Data.Foldable as F
import qualified Data.Set as Set
import Data.List (intercalate)
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.Map as Map
import qualified Data.Text as T
Expand Down
1 change: 0 additions & 1 deletion src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import qualified Data.Map.Merge.Strict as MS
import qualified Data.Monoid
import Data.Monoid.Map (MonoidMap(..))
import qualified Data.Text as T
import Data.Text.Encoding (encodeUtf8)
import qualified Data.Yaml as Yaml
import Distribution.System (OS (..), Platform (..), buildPlatform, Arch(OtherArch))
import qualified Distribution.Text
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/ConfigCmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import qualified Data.Yaml as Yaml
import qualified Options.Applicative as OA
import qualified Options.Applicative.Types as OA
import Options.Applicative.Builder.Extra
import Pantry (completeSnapshotLocation, loadSnapshot)
import Pantry (loadSnapshot)
import Path
import qualified RIO.Map as Map
import RIO.Process (envVarsL)
Expand Down
15 changes: 11 additions & 4 deletions src/Stack/Coverage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ import RIO.Process
import Trace.Hpc.Tix
import Web.Browser (openBrowser)

newtype CoverageException = NonTestSuiteTarget PackageName deriving Typeable

instance Exception CoverageException
instance Show CoverageException where
show (NonTestSuiteTarget name) =
"Can't specify anything except test-suites as hpc report targets (" ++
packageNameString name ++
" is used with a non test-suite target)"

-- | Invoked at the beginning of running with "--coverage"
deleteHpcReports :: HasEnvConfig env => RIO env ()
deleteHpcReports = do
Expand Down Expand Up @@ -235,10 +244,8 @@ generateHpcReportForTargets opts tixFiles targetNames = do
case nc of
CTest testName ->
liftM (pkgPath </>) $ parseRelFile (T.unpack testName ++ "/" ++ T.unpack testName ++ ".tix")
_ -> fail $
"Can't specify anything except test-suites as hpc report targets (" ++
packageNameString name ++
" is used with a non test-suite target)"
_ -> throwIO $ NonTestSuiteTarget name

TargetAll PTProject -> do
pkgPath <- hpcPkgPath name
exists <- doesDirExist pkgPath
Expand Down
8 changes: 6 additions & 2 deletions src/Stack/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ import qualified Data.Text.Encoding as T
import Data.Time (UTCTime)
import Data.Version (showVersion)
import Distribution.Version (mkVersion)
#if MIN_VERSION_path(0,7,0)
import Path hiding (replaceExtension)
#else
import Path
#endif
import Path.Extended (replaceExtension)
import Path.Extra (toFilePathNoTrailingSep)
import Path.IO hiding (canonicalizePath)
import qualified Paths_stack as Meta
Expand All @@ -55,7 +60,6 @@ import Stack.Types.Config
import Stack.Types.Docker
import System.Environment (getEnv,getEnvironment,getProgName,getArgs,getExecutablePath)
import qualified System.FilePath as FP
import System.IO (stderr,stdin)
import System.IO.Error (isDoesNotExistError)
import System.IO.Unsafe (unsafePerformIO)
import qualified System.PosixCompat.User as User
Expand Down Expand Up @@ -151,7 +155,7 @@ getCmdArgs docker imageInfo isRemoteDocker = do
exePath <- ensureDockerStackExe dockerContainerPlatform
cmdArgs args exePath
cmdArgs args exePath = do
exeBase <- exePath -<.> ""
exeBase <- replaceExtension "" exePath
let mountPath = hostBinDir FP.</> toFilePath (filename exeBase)
return (mountPath, args, [], [Mount (toFilePath exePath) mountPath])

Expand Down
1 change: 0 additions & 1 deletion src/Stack/Dot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import Stack.Build.Installed (getInstalled, toInstallMap)
import Stack.Build.Source
import Stack.Constants
import Stack.Package
import Stack.PackageDump (DumpPackage(..))
import Stack.Prelude hiding (Display (..), pkgName, loadPackage)
import qualified Stack.Prelude (pkgName)
import Stack.Runners
Expand Down
1 change: 0 additions & 1 deletion src/Stack/GhcPkg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Stack.Prelude
import qualified Data.ByteString.Char8 as S8
import qualified Data.ByteString.Lazy as BL
import Data.List
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import Path (parent, (</>))
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Ghci/Script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Data.List
import qualified Data.Set as S
import Path
import Stack.Prelude
import System.IO (BufferMode (..), hSetBinaryMode)
import System.IO (hSetBinaryMode)

import Distribution.ModuleName hiding (toFilePath)

Expand Down
1 change: 0 additions & 1 deletion src/Stack/Init.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import qualified Data.Foldable as F
import qualified Data.HashMap.Strict as HM
import qualified Data.IntMap as IntMap
import Data.List.Extra (groupSortOn)
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.List.NonEmpty as NonEmpty
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
Expand Down
6 changes: 3 additions & 3 deletions src/Stack/Lock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ module Stack.Lock
import Pantry.Internal.AesonExtended
import Data.ByteString.Builder (byteString)
import qualified Data.List.NonEmpty as NE
import Data.Map (Map)
import qualified Data.Map as Map
import qualified Data.Yaml as Yaml
import Pantry
import Path (addFileExtension, parent)
import Path (parent)
import Path.Extended (addExtension)
import Path.IO (doesFileExist)
import Stack.Prelude
import Stack.SourceMap
Expand Down Expand Up @@ -95,7 +95,7 @@ lockCachedWanted ::
-> RIO env ( SMWanted, [CompletedPLI]))
-> RIO env SMWanted
lockCachedWanted stackFile resolver fillWanted = do
lockFile <- liftIO $ addFileExtension "lock" stackFile
lockFile <- liftIO $ addExtension ".lock" stackFile
let getLockExists = doesFileExist lockFile
lfb <- view lockFileBehaviorL
readLockFile <-
Expand Down
6 changes: 2 additions & 4 deletions src/Stack/Ls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ module Stack.Ls
, listDependenciesCmd
) where

import Control.Exception (Exception, throw)
import Control.Monad (when)
import Control.Exception (throw)
import Data.Aeson
import Data.Array.IArray ((//), elems)
import Stack.Prelude hiding (Snapshot (..))
Expand All @@ -19,11 +18,10 @@ import qualified Data.List as L
import Data.Text hiding (pack, intercalate)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Typeable (Typeable)
import qualified Data.Vector as V
import Network.HTTP.StackClient (httpJSON, addRequestHeader, getResponseBody, parseRequest, hAccept)
import qualified Options.Applicative as OA
import Options.Applicative ((<|>), idm)
import Options.Applicative (idm)
import Options.Applicative.Builder.Extra (boolFlags)
import Path
import RIO.PrettyPrint (useColorL)
Expand Down
1 change: 0 additions & 1 deletion src/Stack/New.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Stack.New

import Stack.Prelude
import Control.Monad.Trans.Writer.Strict
import Control.Monad (void)
import Data.ByteString.Builder (lazyByteString)
import qualified Data.ByteString.Lazy as LB
import Data.Conduit
Expand Down
1 change: 0 additions & 1 deletion src/Stack/Nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module Stack.Nix
import Stack.Prelude
import qualified Data.Text as T
import Data.Version (showVersion)
import Lens.Micro (set)
import Path.IO
import qualified Paths_stack as Meta
import Stack.Config (getInContainer, withBuildConfig)
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Options/DotParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Data.Char (isSpace)
import Data.List.Split (splitOn)
import qualified Data.Set as Set
import qualified Data.Text as T
import Distribution.Types.PackageName(PackageName, mkPackageName)
import Distribution.Types.PackageName(mkPackageName)
import Options.Applicative
import Options.Applicative.Builder.Extra
import Stack.Dot
Expand Down
7 changes: 5 additions & 2 deletions src/Stack/Package.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ScopedTypeVariables #-}
Expand Down Expand Up @@ -28,7 +29,6 @@ module Stack.Package
) where

import Data.List (find, isPrefixOf, unzip)
import Data.Maybe (maybe)
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import qualified Data.Text as T
Expand All @@ -45,7 +45,6 @@ import Distribution.Simple.Glob (matchDirFileGlob)
import Distribution.System (OS (..), Arch, Platform (..))
import qualified Distribution.Text as D
import qualified Distribution.Types.CondTree as Cabal
import Distribution.Types.Dependency (depPkgName, depVerRange)
import qualified Distribution.Types.ExeDependency as Cabal
import Distribution.Types.ForeignLib
import qualified Distribution.Types.LegacyExeDependency as Cabal
Expand All @@ -55,7 +54,11 @@ import qualified Distribution.Types.UnqualComponentName as Cabal
import qualified Distribution.Verbosity as D
import Distribution.Version (mkVersion, orLaterVersion, anyVersion)
import qualified HiFileParser as Iface
#if MIN_VERSION_path(0,7,0)
import Path as FL hiding (replaceExtension)
#else
import Path as FL
#endif
import Path.Extra
import Path.IO hiding (findFiles)
import Stack.Build.Installed
Expand Down
2 changes: 0 additions & 2 deletions src/Stack/Path.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ import Stack.Prelude
import Data.List (intercalate)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Lens.Micro (lens)
import qualified Options.Applicative as OA
import Pantry (HasPantryConfig (..))
import Path
import Path.Extra
import Stack.Constants
Expand Down
2 changes: 0 additions & 2 deletions src/Stack/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ import qualified Data.Conduit.Binary as CB
import qualified Data.Conduit.List as CL
import Data.Conduit.Process.Typed (withLoggedProcess_, createSource, byteStringInput)
import RIO.Process (HasProcessContext (..), ProcessContext, setStdin, closed, getStderr, getStdout, proc, withProcessWait_, setStdout, setStderr, ProcessConfig, readProcess_, workingDirL, waitExitCode)
import Data.Text.Encoding (decodeUtf8With)
import Data.Text.Encoding.Error (lenientDecode)

import qualified Data.Text.IO as T
import qualified RIO.Text as T
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Runners.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Stack.Storage.User (upgradeChecksSince, logUpgradeCheck)
import Stack.Types.Config
import Stack.Types.Docker (dockerEnable)
import Stack.Types.Nix (nixEnable)
import Stack.Types.Version (stackMinorVersion, stackVersion, minorVersion)
import Stack.Types.Version (stackMinorVersion, minorVersion)
import System.Console.ANSI (hSupportsANSIWithoutEmulation)
import System.Terminal (getTerminalWidth)

Expand Down
Loading

0 comments on commit e0e7e28

Please sign in to comment.