Skip to content

Commit

Permalink
Merge pull request #6446 from commercialhaskell/other-prefix
Browse files Browse the repository at this point in the history
Remove various prefixes from field names of types
  • Loading branch information
mpilgrem authored Jan 18, 2024
2 parents 023fb60 + 07bd438 commit 8714271
Show file tree
Hide file tree
Showing 28 changed files with 136 additions and 130 deletions.
4 changes: 2 additions & 2 deletions src/GHC/Utils/GhcPkg/Main/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,8 @@ readParseDatabase mode path = do
[InstalledPackageInfo]
-> GhcPkg.DbOpenMode mode GhcPkg.PackageDbLock
-> RIO env (PackageDB mode)
mkPackageDB pkgs lock = do
pure $ PackageDB
mkPackageDB pkgs lock =
pure PackageDB
{ location = path
, packageDbLock = lock
, packages = pkgs
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ flagCacheKey installed = do
installationRoot <- installationRootLocal
case installed of
Library _ installedInfo -> do
let gid = installedInfo.iliId
let gid = installedInfo.ghcPkgId
pure $ configCacheKey installationRoot (ConfigCacheTypeFlagLibrary gid)
Executable ident -> pure $
configCacheKey installationRoot (ConfigCacheTypeFlagExecutable ident)
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/ExecutePackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ singleTest topts testsToRun ac ee task installedMap = do
idMap <- liftIO $ readTVarIO ee.ghcPkgIds
pure $ Map.lookup (taskProvides task) idMap
let pkgGhcIdList = case installed of
Just (Library _ libInfo) -> [libInfo.iliId]
Just (Library _ libInfo) -> [libInfo.ghcPkgId]
_ -> []
-- doctest relies on template-haskell in QuickCheck-based tests
thGhcId <-
Expand Down
23 changes: 12 additions & 11 deletions src/Stack/Build/Installed.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

-- Determine which packages are already installed
module Stack.Build.Installed
Expand Down Expand Up @@ -298,12 +299,12 @@ gatherAndTransformSubLoadHelper lh =
(_, Library _ existingLibInfo)
= ( pLoc
, Library pn existingLibInfo
{ iliSublib = Map.union
incomingLibInfo.iliSublib
existingLibInfo.iliSublib
, iliId = if isJust lh.lhSublibrary
then existingLibInfo.iliId
else incomingLibInfo.iliId
{ subLib = Map.union
incomingLibInfo.subLib
existingLibInfo.subLib
, ghcPkgId = if isJust lh.lhSublibrary
then existingLibInfo.ghcPkgId
else incomingLibInfo.ghcPkgId
}
)
onPreviousLoadHelper newVal _oldVal = newVal
Expand All @@ -316,5 +317,5 @@ gatherAndTransformSubLoadHelper lh =
(Library (PackageIdentifier _sublibMungedPackageName version) libInfo)
= Library
(PackageIdentifier key version)
libInfo {iliSublib = Map.singleton sd.libraryName libInfo.iliId}
libInfo { subLib = Map.singleton sd.libraryName libInfo.ghcPkgId }
updateAsSublib _ v = v
2 changes: 1 addition & 1 deletion src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ checkBuildCache oldCache files = do
go fp _ _ | takeFileName fp == "cabal_macros.h" = pure (Set.empty, Map.empty)
-- Common case where it's in the cache and on the filesystem.
go fp (Just digest') (Just fci)
| fci.fciHash == digest' = pure (Set.empty, Map.singleton fp fci)
| fci.hash == digest' = pure (Set.empty, Map.singleton fp fci)
| otherwise =
pure (Set.singleton fp, Map.singleton fp $ FileCacheInfo digest')
-- Missing file. Add it to dirty files, but no FileCacheInfo.
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ configFromConfigMonoid
os = defOS
platform = Platform arch os
requireStackVersion = simplifyVersionRange
configMonoid.requireStackVersion.getIntersectingVersionRange
configMonoid.requireStackVersion.intersectingVersionRange
compilerCheck = fromFirst MatchMinor configMonoid.compilerCheck
platformVariant <- liftIO $
maybe PlatformVariantNone PlatformVariant <$> lookupEnv platformVariantEnvVar
Expand Down
6 changes: 3 additions & 3 deletions src/Stack/Config/Docker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Stack.Types.Docker
, DockerOptsMonoid (..), dockerImageArgName
)
import Stack.Types.Resolver ( AbstractResolver (..) )
import Stack.Types.Version ( getIntersectingVersionRange )
import Stack.Types.Version ( IntersectingVersionRange (..) )

-- | Type representing exceptions thrown by functions exported by the
-- "Stack.Config.Docker" module.
Expand Down Expand Up @@ -105,9 +105,9 @@ dockerOptsFromMonoid mproject maresolver dockerMonoid = do
setUser = getFirst dockerMonoid.setUser
requireDockerVersion =
simplifyVersionRange
dockerMonoid.requireDockerVersion.getIntersectingVersionRange
dockerMonoid.requireDockerVersion.intersectingVersionRange
stackExe = getFirst dockerMonoid.stackExe
pure $ DockerOpts
pure DockerOpts
{ enable
, image
, registryLogin
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Config/Nix.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ nixOptsFromMonoid nixMonoid os = do

when (not (null packages) && isJust initFile) $
throwIO NixCannotUseShellFileAndPackagesException
pure $ NixOpts
pure NixOpts
{ enable
, pureShell
, packages
Expand Down
10 changes: 5 additions & 5 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -536,12 +536,12 @@ runGhci
++ M.foldMapWithKey subDepsPackageUnhide exposeInternalDep
else []
oneWordOpts bio
| shouldHidePackages = bio.bioOneWordOpts ++ bio.bioPackageFlags
| otherwise = bio.bioOneWordOpts
| shouldHidePackages = bio.oneWordOpts ++ bio.packageFlags
| otherwise = bio.oneWordOpts
genOpts = nubOrd
(concatMap (concatMap (oneWordOpts . snd) . (.ghciPkgOpts)) pkgs)
(omittedOpts, ghcOpts) = L.partition badForGhci $
concatMap (concatMap ((.bioOpts) . snd) . (.ghciPkgOpts)) pkgs
concatMap (concatMap ((.opts) . snd) . (.ghciPkgOpts)) pkgs
++ map
T.unpack
( fold config.ghcOptionsByCat
Expand Down Expand Up @@ -623,7 +623,7 @@ writeMacrosFile ::
writeMacrosFile outputDirectory pkgs = do
fps <- fmap (nubOrd . catMaybes . concat) $
forM pkgs $ \pkg -> forM pkg.ghciPkgOpts $ \(_, bio) -> do
let cabalMacros = bio.bioCabalMacros
let cabalMacros = bio.cabalMacros
exists <- liftIO $ doesFileExist cabalMacros
if exists
then pure $ Just cabalMacros
Expand Down Expand Up @@ -1076,7 +1076,7 @@ checkForIssues pkgs =
where
(xs, ys) = L.partition (any f . snd) compsWithOpts
compsWithOpts = map (\(k, bio) ->
(k, bio.bioOneWordOpts ++ bio.bioOpts)) compsWithBios
(k, bio.oneWordOpts ++ bio.opts)) compsWithBios
compsWithBios =
[ ((pkg.ghciPkgName, c), bio)
| pkg <- pkgs
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/New.hs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ settingsFromRepoTemplatePath (RepoTemplatePath GitHub user name) = do
basicAuthMsg altGitHubTokenEnvVar
pure $ Just (gitHubBasicAuthType, fromString wantAltGitHubToken)
else pure Nothing
pure $ TemplateDownloadSettings
pure TemplateDownloadSettings
{ tplDownloadUrl = concat
[ "https://api.github.com/repos/"
, T.unpack user
Expand Down
32 changes: 16 additions & 16 deletions src/Stack/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ generatePkgDescOpts
generateBuildInfoOpts :: BioInput -> BuildInfoOpts
generateBuildInfoOpts bi =
BuildInfoOpts
{ bioOpts =
{ opts =
ghcOpts
++ fmap ("-optP" <>) bi.buildInfo.cppOptions
-- NOTE for future changes: Due to this use of nubOrd (and other uses
Expand All @@ -290,10 +290,10 @@ generateBuildInfoOpts bi =
-- "--main-is" being removed.
--
-- See https://github.com/commercialhaskell/stack/issues/1255
, bioOneWordOpts = nubOrd $ concat
, oneWordOpts = nubOrd $ concat
[extOpts, srcOpts, includeOpts, libOpts, fworks, cObjectFiles]
, bioPackageFlags = deps
, bioCabalMacros = componentAutogen </> relFileCabalMacrosH
, packageFlags = deps
, cabalMacros = componentAutogen </> relFileCabalMacrosH
}
where
cObjectFiles = mapMaybe
Expand Down Expand Up @@ -503,10 +503,10 @@ flagMap = M.fromList . map pair
pair = flagName &&& flagDefault

data ResolveConditions = ResolveConditions
{ rcFlags :: Map FlagName Bool
, rcCompilerVersion :: ActualCompiler
, rcOS :: OS
, rcArch :: Arch
{ flags :: Map FlagName Bool
, compilerVersion :: ActualCompiler
, os :: OS
, arch :: Arch
}

-- | Generic a @ResolveConditions@ using sensible defaults.
Expand All @@ -516,10 +516,10 @@ mkResolveConditions ::
-> Map FlagName Bool -- ^ enabled flags
-> ResolveConditions
mkResolveConditions compilerVersion (Platform arch os) flags = ResolveConditions
{ rcFlags = flags
, rcCompilerVersion = compilerVersion
, rcOS = os
, rcArch = arch
{ flags
, compilerVersion
, os
, arch
}

-- | Resolve the condition tree for the library.
Expand Down Expand Up @@ -547,13 +547,13 @@ resolveConditions rc addDeps (CondNode lib deps cs) = basic <> children
CAnd cx cy -> condSatisfied cx && condSatisfied cy
varSatisfied v =
case v of
OS os -> os == rc.rcOS
Arch arch -> arch == rc.rcArch
PackageFlag flag -> fromMaybe False $ M.lookup flag rc.rcFlags
OS os -> os == rc.os
Arch arch -> arch == rc.arch
PackageFlag flag -> fromMaybe False $ M.lookup flag rc.flags
-- NOTE: ^^^^^ This should never happen, as all flags which are used
-- must be declared. Defaulting to False.
Impl flavor range ->
case (flavor, rc.rcCompilerVersion) of
case (flavor, rc.compilerVersion) of
(GHC, ACGhc vghc) -> vghc `withinRange` range
_ -> False

Expand Down
2 changes: 1 addition & 1 deletion src/Stack/SDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ getSDistTarball mpvpBounds pkgDir = do
(installedMap, _globalDumpPkgs, _snapshotDumpPkgs, _localDumpPkgs) <-
getInstalled installMap
let deps = Map.fromList
[ (pid, libInfo.iliId)
[ (pid, libInfo.ghcPkgId)
| (_, Library pid libInfo) <- Map.elems installedMap]
prettyInfoL
[ flow "Getting the file list for"
Expand Down
28 changes: 14 additions & 14 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ setupEnv needTargets buildOptsCLI mResolveMissingGHC = do
menv0 <- view processContextL
env <- either throwM (pure . removeHaskellEnvVars)
$ augmentPathMap
(map toFilePath ghcBin.edBins)
(map toFilePath ghcBin.bins)
(view envVarsL menv0)
menv <- mkProcessContext env

Expand Down Expand Up @@ -932,7 +932,7 @@ runWithMSYS mmsysPaths inner = do
Just msysPaths -> do
envars <- either throwM pure $
augmentPathMap
(map toFilePath msysPaths.edBins)
(map toFilePath msysPaths.bins)
(view envVarsL pc0)
mkProcessContext envars
let envMsys
Expand Down Expand Up @@ -1110,7 +1110,7 @@ ensureMsys sopts getSetupInfo' = do
osKey <- getOSKey "MSYS2" msysDir
config <- view configL
VersionedDownloadInfo version info <-
case Map.lookup osKey si.siMsys2 of
case Map.lookup osKey si.msys2 of
Just x -> pure x
Nothing -> prettyThrowIO $ MSYS2NotFound osKey
let tool = Tool (PackageIdentifier (mkPackageName "msys2") version)
Expand Down Expand Up @@ -1259,12 +1259,12 @@ ensureCompiler sopts getSetupInfo' = do
Nothing -> ensureSandboxedCompiler sopts getSetupInfo'
Just cp -> do
let paths = ExtraDirs
{ edBins = [parent cp.compiler]
, edInclude = [], edLib = []
{ bins = [parent cp.compiler]
, include = []
, lib = []
}
pure (cp, paths)


-- | Runs @STACK_ROOT\/hooks\/ghc-install.sh@.
--
-- Reads and possibly validates the output of the process as the GHC binary and
Expand Down Expand Up @@ -1354,7 +1354,7 @@ ensureSandboxedCompiler sopts getSetupInfo' = do
wc <- either throwIO (pure . whichCompiler) $ wantedToActual wanted
menv0 <- view processContextL
m <- either throwM pure
$ augmentPathMap (toFilePath <$> paths.edBins) (view envVarsL menv0)
$ augmentPathMap (toFilePath <$> paths.bins) (view envVarsL menv0)
menv <- mkProcessContext (removeHaskellEnvVars m)

names <-
Expand All @@ -1368,10 +1368,10 @@ ensureSandboxedCompiler sopts getSetupInfo' = do
-- sandbox. This led to a specific issue on Windows with GHC 9.0.1. See
-- https://gitlab.haskell.org/ghc/ghc/-/issues/20074. Instead, now, we look
-- on the paths specified only.
let loop [] = prettyThrowIO $ SandboxedCompilerNotFound names paths.edBins
let loop [] = prettyThrowIO $ SandboxedCompilerNotFound names paths.bins
loop (x:xs) = do
res <- liftIO $
D.findExecutablesInDirectories (map toFilePath paths.edBins) x
D.findExecutablesInDirectories (map toFilePath paths.bins) x
case res of
[] -> loop xs
compiler:rest -> do
Expand Down Expand Up @@ -1985,7 +1985,7 @@ downloadAndInstallCompiler ghcBuild si wanted@(WCGhc version) versionCheck mbind
)
_ -> do
ghcKey <- getGhcKey ghcBuild
case Map.lookup ghcKey si.siGHCs of
case Map.lookup ghcKey si.ghcByVersion of
Nothing -> throwM $ UnknownOSKey ghcKey
Just pairs_ ->
getWantedCompilerInfo ghcKey versionCheck wanted ACGhc pairs_
Expand All @@ -2011,7 +2011,7 @@ downloadAndInstallCompiler ghcBuild si wanted@(WCGhc version) versionCheck mbind
let tool = Tool $ PackageIdentifier ghcPkgName selectedVersion
downloadAndInstallTool
config.localPrograms
downloadInfo.gdiDownloadInfo
downloadInfo.downloadInfo
tool
(installer si)

Expand Down Expand Up @@ -2289,14 +2289,14 @@ installGHCPosix downloadInfo _ archiveFile archiveType tempDir destDir = do

-- Data.Map.union provides a left-biased union, so mGccEnv will prevail
let ghcConfigureEnv =
fromMaybe Map.empty mGccEnv `Map.union` downloadInfo.gdiConfigureEnv
fromMaybe Map.empty mGccEnv `Map.union` downloadInfo.configureEnv

logSticky "Configuring GHC ..."
runStep "configuring" dir
ghcConfigureEnv
(toFilePath $ dir </> relFileConfigure)
( ("--prefix=" ++ toFilePath destDir)
: map T.unpack downloadInfo.gdiConfigureOpts
: map T.unpack downloadInfo.configureOpts
)

logSticky "Installing GHC ..."
Expand Down Expand Up @@ -2457,7 +2457,7 @@ setup7z si = do
ensureDir dir
let exeDestination = dir </> relFile7zexe
dllDestination = dir </> relFile7zdll
case (si.siSevenzDll, si.siSevenzExe) of
case (si.sevenzDll, si.sevenzExe) of
(Just sevenzDll, Just sevenzExe) -> do
_ <- downloadOrUseLocal "7z.dll" sevenzDll dllDestination
exePath <- downloadOrUseLocal "7z.exe" sevenzExe exeDestination
Expand Down
16 changes: 8 additions & 8 deletions src/Stack/Setup/Installed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,41 +139,41 @@ extraDirs tool = do
dir <- installDir config.localPrograms tool
case (config.platform, toolNameString tool) of
(Platform _ Cabal.Windows, isGHC -> True) -> pure mempty
{ edBins =
{ bins =
[ dir </> relDirBin
, dir </> relDirMingw </> relDirBin
]
}
(Platform Cabal.I386 Cabal.Windows, "msys2") -> pure mempty
{ edBins =
{ bins =
[ dir </> relDirMingw32 </> relDirBin
, dir </> relDirUsr </> relDirBin
, dir </> relDirUsr </> relDirLocal </> relDirBin
]
, edInclude =
, include =
[ dir </> relDirMingw32 </> relDirInclude
]
, edLib =
, lib =
[ dir </> relDirMingw32 </> relDirLib
, dir </> relDirMingw32 </> relDirBin
]
}
(Platform Cabal.X86_64 Cabal.Windows, "msys2") -> pure mempty
{ edBins =
{ bins =
[ dir </> relDirMingw64 </> relDirBin
, dir </> relDirUsr </> relDirBin
, dir </> relDirUsr </> relDirLocal </> relDirBin
]
, edInclude =
, include =
[ dir </> relDirMingw64 </> relDirInclude
]
, edLib =
, lib =
[ dir </> relDirMingw64 </> relDirLib
, dir </> relDirMingw64 </> relDirBin
]
}
(_, isGHC -> True) -> pure mempty
{ edBins =
{ bins =
[ dir </> relDirBin
]
}
Expand Down
Loading

0 comments on commit 8714271

Please sign in to comment.