From f4309fe384dd889f082e8764e21eba61a3ca2a86 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 13 Feb 2017 16:21:50 +0200 Subject: [PATCH] Remove the NoLocal config type split This was originally done to help implementation of #2805, but we ended up going a different route. --- src/Stack/Build/ConstructPlan.hs | 3 - src/Stack/Build/Source.hs | 19 +++-- src/Stack/BuildPlan.hs | 2 +- src/Stack/Config.hs | 36 ++++----- src/Stack/Ghci.hs | 6 +- src/Stack/Path.hs | 12 +-- src/Stack/Setup.hs | 44 ++++------ src/Stack/Solver.hs | 11 ++- src/Stack/Types/Config.hs | 135 ++++++++----------------------- src/Stack/Types/Internal.hs | 6 +- src/test/Stack/ConfigSpec.hs | 6 +- 11 files changed, 90 insertions(+), 190 deletions(-) diff --git a/src/Stack/Build/ConstructPlan.hs b/src/Stack/Build/ConstructPlan.hs index 9e6d7087f3..63ab68afd3 100644 --- a/src/Stack/Build/ConstructPlan.hs +++ b/src/Stack/Build/ConstructPlan.hs @@ -140,10 +140,7 @@ data Ctx = Ctx instance HasPlatform Ctx instance HasGHCVariant Ctx instance HasConfig Ctx -instance HasBuildConfigNoLocal Ctx instance HasBuildConfig Ctx -instance HasEnvConfigNoLocal Ctx where - envConfigNoLocalL = envConfigL.envConfigNoLocalL instance HasEnvConfig Ctx where envConfigL = lens ctxEnvConfig (\x y -> x { ctxEnvConfig = y }) diff --git a/src/Stack/Build/Source.hs b/src/Stack/Build/Source.hs index 3b6bfdae0f..ac1711ff4b 100644 --- a/src/Stack/Build/Source.hs +++ b/src/Stack/Build/Source.hs @@ -109,7 +109,7 @@ loadSourceMapFull omitWiredIn needTargets boptsCli = do -- Extend extra-deps to encompass targets requested on the command line -- that are not in the snapshot. extraDeps0 <- extendExtraDeps - (bcExtraDeps $ bcLocal bconfig) + (bcExtraDeps bconfig) cliExtraDeps (Map.keysSet $ Map.filter (== STUnknown) targets) @@ -145,7 +145,7 @@ loadSourceMapFull omitWiredIn needTargets boptsCli = do let flags = case ( Map.lookup (Just n) $ boptsCLIFlags boptsCli , Map.lookup Nothing $ boptsCLIFlags boptsCli - , Map.lookup n $ unPackageFlags $ bcFlags $ bcLocal bconfig + , Map.lookup n $ unPackageFlags $ bcFlags bconfig ) of -- Didn't have any flag overrides, fall back to the flags -- defined in the snapshot. @@ -195,7 +195,7 @@ getLocalFlags getLocalFlags bconfig boptsCli name = Map.unions [ Map.findWithDefault Map.empty (Just name) cliFlags , Map.findWithDefault Map.empty Nothing cliFlags - , Map.findWithDefault Map.empty name (unPackageFlags (bcFlags (bcLocal bconfig))) + , Map.findWithDefault Map.empty name (unPackageFlags (bcFlags bconfig)) ] where cliFlags = boptsCLIFlags boptsCli @@ -245,8 +245,7 @@ parseTargetsFromBuildOptsWith -> m (MiniBuildPlan, M.Map PackageName Version, M.Map PackageName SimpleTarget) parseTargetsFromBuildOptsWith rawLocals needTargets boptscli = do $logDebug "Parsing the targets" - bconfig <- view buildConfigNoLocalL - bconfigl <- view buildConfigLocalL + bconfig <- view buildConfigL mbp0 <- case bcResolver bconfig of ResolverCompiler _ -> do @@ -264,16 +263,16 @@ parseTargetsFromBuildOptsWith rawLocals needTargets boptscli = do let snapshot = mpiVersion <$> mbpPackages mbp0 flagExtraDeps <- convertSnapshotToExtra snapshot - (bcExtraDeps bconfigl) + (bcExtraDeps bconfig) rawLocals (catMaybes $ Map.keys $ boptsCLIFlags boptscli) (cliExtraDeps, targets) <- parseTargets needTargets - (bcImplicitGlobal bconfigl) + (bcImplicitGlobal bconfig) snapshot - (flagExtraDeps <> bcExtraDeps bconfigl) + (flagExtraDeps <> bcExtraDeps bconfig) (fst <$> rawLocals) workingDir (boptsCLITargets boptscli) @@ -460,7 +459,7 @@ checkFlagsUsed :: (MonadThrow m, MonadReader env m, HasBuildConfig env) -> Map PackageName snapshot -- ^ snapshot, for error messages -> m () checkFlagsUsed boptsCli lps extraDeps snapshot = do - bconfig <- view buildConfigLocalL + bconfig <- view buildConfigL -- Check if flags specified in stack.yaml and the command line are -- used, see https://github.com/commercialhaskell/stack/issues/617 @@ -512,7 +511,7 @@ extendExtraDeps extraDeps0 cliExtraDeps unknowns = do case errs of [] -> return $ Map.unions $ extraDeps1 : unknowns' _ -> do - bconfig <- view buildConfigLocalL + bconfig <- view buildConfigL throwM $ UnknownTargets (Set.fromList errs) Map.empty -- TODO check the cliExtraDeps for presence in index diff --git a/src/Stack/BuildPlan.hs b/src/Stack/BuildPlan.hs index 62d9e5ce3e..61aa992e8f 100644 --- a/src/Stack/BuildPlan.hs +++ b/src/Stack/BuildPlan.hs @@ -207,7 +207,7 @@ resolveBuildPlan resolveBuildPlan mbp isShadowed packages | Map.null (rsUnknown rs) && Map.null (rsShadowed rs) = return (rsToInstall rs, rsUsedBy rs) | otherwise = do - bconfig <- view buildConfigLocalL + bconfig <- view buildConfigL (caches, _gitShaCaches) <- getPackageCaches let maxVer = Map.fromListWith max $ diff --git a/src/Stack/Config.hs b/src/Stack/Config.hs index fff65f3b40..df0fbf26eb 100644 --- a/src/Stack/Config.hs +++ b/src/Stack/Config.hs @@ -587,24 +587,20 @@ loadBuildConfig mproject config mresolver mcompiler = do extraPackageDBs <- mapM resolveDir' (projectExtraPackageDBs project) return BuildConfig - { bcNoLocal = BuildConfigNoLocal - { bcConfig = config - , bcResolver = loadedResolver - , bcWantedMiniBuildPlan = mbp - , bcGHCVariant = view ghcVariantL miniConfig - } - , bcLocal = BuildConfigLocal - { bcPackageEntries = projectPackages project - , bcExtraDeps = projectExtraDeps project - , bcExtraPackageDBs = extraPackageDBs - , bcStackYaml = stackYamlFP - , bcFlags = projectFlags project - , bcImplicitGlobal = - case mproject of - LCSNoProject -> True - LCSProject _ -> False - LCSNoConfig -> False - } + { bcConfig = config + , bcResolver = loadedResolver + , bcWantedMiniBuildPlan = mbp + , bcGHCVariant = view ghcVariantL miniConfig + , bcPackageEntries = projectPackages project + , bcExtraDeps = projectExtraDeps project + , bcExtraPackageDBs = extraPackageDBs + , bcStackYaml = stackYamlFP + , bcFlags = projectFlags project + , bcImplicitGlobal = + case mproject of + LCSNoProject -> True + LCSProject _ -> False + LCSNoConfig -> False } where miniConfig = loadMiniConfig config @@ -635,14 +631,14 @@ getLocalPackages :: (StackMiniM env m, HasEnvConfig env) => m (Map.Map (Path Abs Dir) TreatLikeExtraDep) getLocalPackages = do - cacheRef <- view $ envConfigLocalL.to envConfigPackagesRef + cacheRef <- view $ envConfigL.to envConfigPackagesRef mcached <- liftIO $ readIORef cacheRef case mcached of Just cached -> return cached Nothing -> do menv <- getMinimalEnvOverride root <- view projectRootL - entries <- view $ buildConfigLocalL.to bcPackageEntries + entries <- view $ buildConfigL.to bcPackageEntries liftM (Map.fromList . concat) $ mapM (resolvePackageEntry menv root) entries diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 1990b7127b..ab8ad7e5b4 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -246,7 +246,7 @@ checkTargets checkTargets mp = do let filtered = M.filter (== STUnknown) mp unless (M.null filtered) $ do - bconfig <- view buildConfigLocalL + bconfig <- view buildConfigL throwM $ UnknownTargets (M.keysSet filtered) M.empty (bcStackYaml bconfig) getAllLocalTargets @@ -563,10 +563,8 @@ makeGhciPkgInfo makeGhciPkgInfo buildOptsCLI sourceMap installedMap locals addPkgs mfileTargets name cabalfp target = do bopts <- view buildOptsL econfig <- view envConfigL - bconfignl <- view buildConfigNoLocalL - bconfigl <- view buildConfigLocalL + bconfig <- view buildConfigL compilerVersion <- view actualCompilerVersionL - let bconfig = BuildConfig bconfignl bconfigl let config = PackageConfig { packageConfigEnableTests = True diff --git a/src/Stack/Path.hs b/src/Stack/Path.hs index 2c387ea62d..ee7aab6283 100644 --- a/src/Stack/Path.hs +++ b/src/Stack/Path.hs @@ -39,8 +39,7 @@ path path keys = do -- We must use a BuildConfig from an EnvConfig to ensure that it contains the -- full environment info including GHC paths etc. - bcnl <- view $ envConfigL.buildConfigNoLocalL - bcl <- view $ envConfigL.buildConfigLocalL + bc <- view $ envConfigL.buildConfigL -- This is the modified 'bin-path', -- including the local GHC or MSYS if not configured to operate on -- global GHC. @@ -80,7 +79,7 @@ path keys = else key <> ": ") <> path' (PathInfo - (BuildConfig bcnl bcl) + bc menv snap plocal @@ -119,12 +118,9 @@ data PathInfo = PathInfo instance HasPlatform PathInfo instance HasConfig PathInfo -instance HasBuildConfigNoLocal PathInfo where - buildConfigNoLocalL = lens piBuildConfig (\x y -> x { piBuildConfig = y }) - . buildConfigNoLocalL instance HasBuildConfig PathInfo where - buildConfigLocalL = lens piBuildConfig (\x y -> x { piBuildConfig = y }) - . buildConfigLocalL + buildConfigL = lens piBuildConfig (\x y -> x { piBuildConfig = y }) + . buildConfigL -- | The paths of interest to a user. The first tuple string is used -- for a description that the optparse flag uses, and the second diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index 23b8286018..d390eb515f 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -216,8 +216,8 @@ setupEnv :: (StackM env m, HasBuildConfig env, HasGHCVariant env) -> m EnvConfig setupEnv mResolveMissingGHC = do config <- view configL - bconfig <- view buildConfigNoLocalL - stackYaml <- view $ buildConfigLocalL.to bcStackYaml + bconfig <- view buildConfigL + let stackYaml = bcStackYaml bconfig platform <- view platformL wcVersion <- view wantedCompilerVersionL wc <- view $ wantedCompilerVersionL.whichCompilerL @@ -253,19 +253,13 @@ setupEnv mResolveMissingGHC = do $logDebug "Resolving package entries" packagesRef <- liftIO $ newIORef Nothing - bcnl <- view buildConfigNoLocalL - bcl <- view buildConfigLocalL + bc <- view buildConfigL let envConfig0 = EnvConfig - { ecNoLocal = EnvConfigNoLocal - { envConfigBuildConfigNoLocal = bcnl - , envConfigCabalVersion = cabalVer - , envConfigCompilerVersion = compilerVer - , envConfigCompilerBuild = compilerBuild - } - , ecLocal = EnvConfigLocal - { envConfigBuildConfigLocal = bcl - , envConfigPackagesRef = packagesRef - } + { envConfigBuildConfig = bc + , envConfigCabalVersion = cabalVer + , envConfigCompilerVersion = compilerVer + , envConfigCompilerBuild = compilerBuild + , envConfigPackagesRef = packagesRef } -- extra installation bin directories @@ -335,22 +329,16 @@ setupEnv mResolveMissingGHC = do (Map.insert es eo m', ()) return eo - bconfigl <- view buildConfigLocalL return EnvConfig - { ecNoLocal = EnvConfigNoLocal - { envConfigBuildConfigNoLocal = bconfig - { bcConfig = maybe id addIncludeLib mghcBin - (view configL bconfig) - { configEnvOverride = getEnvOverride' } - } - , envConfigCabalVersion = cabalVer - , envConfigCompilerVersion = compilerVer - , envConfigCompilerBuild = compilerBuild - } - , ecLocal = EnvConfigLocal - { envConfigBuildConfigLocal = bconfigl - , envConfigPackagesRef = envConfigPackagesRef $ ecLocal envConfig0 + { envConfigBuildConfig = bconfig + { bcConfig = maybe id addIncludeLib mghcBin + (view configL bconfig) + { configEnvOverride = getEnvOverride' } } + , envConfigCabalVersion = cabalVer + , envConfigCompilerVersion = compilerVer + , envConfigCompilerBuild = compilerBuild + , envConfigPackagesRef = envConfigPackagesRef envConfig0 } -- | Add the include and lib paths to the given Config diff --git a/src/Stack/Solver.hs b/src/Stack/Solver.hs index 40c0febfad..154e54ad16 100644 --- a/src/Stack/Solver.hs +++ b/src/Stack/Solver.hs @@ -622,10 +622,9 @@ solveExtraDeps => Bool -- ^ modify stack.yaml? -> m () solveExtraDeps modStackYaml = do - bconfignl <- view buildConfigNoLocalL - bconfigl <- view buildConfigLocalL + bconfig <- view buildConfigL - let stackYaml = bcStackYaml bconfigl + let stackYaml = bcStackYaml bconfig relStackYaml <- prettyPath stackYaml $logInfo $ "Using configuration file: " <> T.pack relStackYaml @@ -645,9 +644,9 @@ solveExtraDeps modStackYaml = do (bundle, _) <- cabalPackagesCheck cabalfps noPkgMsg (Just dupPkgFooter) let gpds = Map.elems $ fmap snd bundle - oldFlags = unPackageFlags (bcFlags bconfigl) - oldExtraVersions = bcExtraDeps bconfigl - resolver = bcResolver bconfignl + oldFlags = unPackageFlags (bcFlags bconfig) + oldExtraVersions = bcExtraDeps bconfig + resolver = bcResolver bconfig oldSrcs = gpdPackages gpds oldSrcFlags = Map.intersection oldFlags oldSrcs oldExtraFlags = Map.intersection oldFlags oldExtraVersions diff --git a/src/Stack/Types/Config.hs b/src/Stack/Types/Config.hs index a92aa4eb78..01646ffe4d 100644 --- a/src/Stack/Types/Config.hs +++ b/src/Stack/Types/Config.hs @@ -35,12 +35,9 @@ module Stack.Types.Config ,explicitSetupDeps ,getMinimalEnvOverride -- ** BuildConfig & HasBuildConfig - ,BuildConfigNoLocal(..) - ,BuildConfigLocal(..) ,BuildConfig(..) ,stackYamlL ,projectRootL - ,HasBuildConfigNoLocal(..) ,HasBuildConfig(..) -- ** GHCVariant & HasGHCVariant ,GHCVariant(..) @@ -53,9 +50,6 @@ module Stack.Types.Config ,StackMiniM -- ** EnvConfig & HasEnvConfig ,EnvConfig(..) - ,EnvConfigNoLocal(..) - ,EnvConfigLocal(..) - ,HasEnvConfigNoLocal(..) ,HasEnvConfig(..) ,getCompilerPath -- * Details @@ -175,7 +169,6 @@ module Stack.Types.Config ,configUrlsL ,cabalVersionL ,whichCompilerL - ,buildConfigL -- * Lens reexport ,view ,to @@ -512,7 +505,7 @@ readColorWhen = do -- 'Config' in order to determine the values here. -- -- These are the components which know nothing about local configuration. -data BuildConfigNoLocal = BuildConfigNoLocal +data BuildConfig = BuildConfig { bcConfig :: !Config , bcResolver :: !LoadedResolver -- ^ How we resolve which dependencies to install given a set of @@ -521,11 +514,7 @@ data BuildConfigNoLocal = BuildConfigNoLocal -- ^ Build plan wanted for this build , bcGHCVariant :: !GHCVariant -- ^ The variant of GHC used to select a GHC bindist. - } - --- | The local parts of 'BuildConfigNoLocal' -data BuildConfigLocal = BuildConfigLocal - { bcPackageEntries :: ![PackageEntry] + , bcPackageEntries :: ![PackageEntry] -- ^ Local packages , bcExtraDeps :: !(Map PackageName Version) -- ^ Extra dependencies specified in configuration. @@ -549,21 +538,16 @@ data BuildConfigLocal = BuildConfigLocal -- for providing better error messages. } -data BuildConfig = BuildConfig - { bcNoLocal :: !BuildConfigNoLocal - , bcLocal :: !BuildConfigLocal - } - stackYamlL :: HasBuildConfig env => Lens' env (Path Abs File) -stackYamlL = buildConfigLocalL.lens bcStackYaml (\x y -> x { bcStackYaml = y }) +stackYamlL = buildConfigL.lens bcStackYaml (\x y -> x { bcStackYaml = y }) -- | Directory containing the project's stack.yaml file projectRootL :: HasBuildConfig env => Getting r env (Path Abs Dir) projectRootL = stackYamlL.to parent -- | Configuration after the environment has been setup. -data EnvConfigNoLocal = EnvConfigNoLocal - {envConfigBuildConfigNoLocal :: !BuildConfigNoLocal +data EnvConfig = EnvConfig + {envConfigBuildConfig :: !BuildConfig ,envConfigCabalVersion :: !Version -- ^ This is the version of Cabal that stack will use to compile Setup.hs files -- in the build process. @@ -576,19 +560,10 @@ data EnvConfigNoLocal = EnvConfigNoLocal -- 'wantedCompilerL', which provides the version specified by the -- build plan. ,envConfigCompilerBuild :: !CompilerBuild - } - -data EnvConfigLocal = EnvConfigLocal - {envConfigBuildConfigLocal :: !BuildConfigLocal ,envConfigPackagesRef :: !(IORef (Maybe (Map (Path Abs Dir) TreatLikeExtraDep))) -- ^ Cache for 'getLocalPackages'. } -data EnvConfig = EnvConfig - { ecNoLocal :: !EnvConfigNoLocal - , ecLocal :: !EnvConfigLocal - } - -- | Value returned by 'Stack.Config.loadConfig'. data LoadConfig m = LoadConfig { lcConfig :: !Config @@ -1312,7 +1287,7 @@ platformGhcRelDir :: (MonadReader env m, HasEnvConfig env, MonadThrow m) => m (Path Rel Dir) platformGhcRelDir = do - ec <- view envConfigNoLocalL + ec <- view envConfigL verOnly <- platformGhcVerOnlyRelDirStr parseRelDir (mconcat [ verOnly , compilerBuildSuffix (envConfigCompilerBuild ec)]) @@ -1369,10 +1344,8 @@ packageDatabaseLocal = do return $ root $(mkRelDir "pkgdb") -- | Extra package databases -packageDatabaseExtra :: (MonadThrow m, MonadReader env m, HasEnvConfig env) => m [Path Abs Dir] -packageDatabaseExtra = do - bc <- view buildConfigLocalL - return $ bcExtraPackageDBs bc +packageDatabaseExtra :: (MonadReader env m, HasEnvConfig env) => m [Path Abs Dir] +packageDatabaseExtra = view $ buildConfigL.to bcExtraPackageDBs -- | Directory for holding flag cache information flagCacheLocal :: (MonadThrow m, MonadReader env m, HasEnvConfig env) => m (Path Abs Dir) @@ -1824,39 +1797,25 @@ class HasPlatform env where -- | Class for environment values which have a GHCVariant class HasGHCVariant env where ghcVariantL :: Lens' env GHCVariant - default ghcVariantL :: HasBuildConfigNoLocal env => Lens' env GHCVariant - ghcVariantL = buildConfigNoLocalL.ghcVariantL + default ghcVariantL :: HasBuildConfig env => Lens' env GHCVariant + ghcVariantL = buildConfigL.ghcVariantL {-# INLINE ghcVariantL #-} -- | Class for environment values that can provide a 'Config'. class HasPlatform env => HasConfig env where configL :: Lens' env Config - default configL :: HasBuildConfigNoLocal env => Lens' env Config - configL = buildConfigNoLocalL.lens bcConfig (\x y -> x { bcConfig = y }) + default configL :: HasBuildConfig env => Lens' env Config + configL = buildConfigL.lens bcConfig (\x y -> x { bcConfig = y }) {-# INLINE configL #-} -class HasConfig env => HasBuildConfigNoLocal env where - buildConfigNoLocalL :: Lens' env BuildConfigNoLocal - default buildConfigNoLocalL :: HasEnvConfigNoLocal env => Lens' env BuildConfigNoLocal - buildConfigNoLocalL = envConfigNoLocalL.lens - envConfigBuildConfigNoLocal - (\x y -> x { envConfigBuildConfigNoLocal = y }) - --- | Class for environment values that can provide a 'BuildConfig'. -class HasBuildConfigNoLocal env => HasBuildConfig env where - buildConfigLocalL :: Lens' env BuildConfigLocal - default buildConfigLocalL :: HasEnvConfig env => Lens' env BuildConfigLocal - buildConfigLocalL = envConfigLocalL.lens - envConfigBuildConfigLocal - (\x y -> x { envConfigBuildConfigLocal = y }) - -class (HasBuildConfigNoLocal env, HasGHCVariant env) => HasEnvConfigNoLocal env where - envConfigNoLocalL :: Lens' env EnvConfigNoLocal - -class (HasBuildConfig env, HasEnvConfigNoLocal env) => HasEnvConfig env where - envConfigLocalL :: Lens' env EnvConfigLocal - envConfigLocalL = envConfigL.lens ecLocal (\x y -> x { ecLocal = y }) - {-# INLINE envConfigLocalL #-} +class HasConfig env => HasBuildConfig env where + buildConfigL :: Lens' env BuildConfig + default buildConfigL :: HasEnvConfig env => Lens' env BuildConfig + buildConfigL = envConfigL.lens + envConfigBuildConfig + (\x y -> x { envConfigBuildConfig = y }) + +class (HasBuildConfig env, HasGHCVariant env) => HasEnvConfig env where envConfigL :: Lens' env EnvConfig ----------------------------------- @@ -1869,51 +1828,28 @@ instance HasPlatform (Platform,PlatformVariant) where instance HasPlatform Config where platformL = lens configPlatform (\x y -> x { configPlatform = y }) platformVariantL = lens configPlatformVariant (\x y -> x { configPlatformVariant = y }) -instance HasPlatform BuildConfigNoLocal instance HasPlatform BuildConfig -instance HasPlatform EnvConfigNoLocal instance HasPlatform EnvConfig instance HasGHCVariant GHCVariant where ghcVariantL = id {-# INLINE ghcVariantL #-} -instance HasGHCVariant BuildConfigNoLocal where +instance HasGHCVariant BuildConfig where ghcVariantL = lens bcGHCVariant (\x y -> x { bcGHCVariant = y }) -instance HasGHCVariant BuildConfig -instance HasGHCVariant EnvConfigNoLocal instance HasGHCVariant EnvConfig instance HasConfig Config where configL = id {-# INLINE configL #-} -instance HasConfig BuildConfigNoLocal where +instance HasConfig BuildConfig where configL = lens bcConfig (\x y -> x { bcConfig = y }) -instance HasConfig BuildConfig -instance HasConfig EnvConfigNoLocal instance HasConfig EnvConfig -instance HasBuildConfigNoLocal BuildConfigNoLocal where - buildConfigNoLocalL = id - {-# INLINE buildConfigNoLocalL #-} -instance HasBuildConfigNoLocal BuildConfig where - buildConfigNoLocalL = lens - bcNoLocal - (\x y -> x { bcNoLocal = y }) -instance HasBuildConfigNoLocal EnvConfigNoLocal -instance HasBuildConfigNoLocal EnvConfig - instance HasBuildConfig BuildConfig where - buildConfigLocalL = lens bcLocal (\x y -> x { bcLocal = y}) - {-# INLINE buildConfigLocalL #-} + buildConfigL = id + {-# INLINE buildConfigL #-} instance HasBuildConfig EnvConfig -instance HasEnvConfigNoLocal EnvConfigNoLocal where - envConfigNoLocalL = id - {-# INLINE envConfigNoLocalL #-} -instance HasEnvConfigNoLocal EnvConfig where - envConfigNoLocalL = lens ecNoLocal (\x y -> x { ecNoLocal = y }) - {-# INLINE envConfigNoLocalL #-} - instance HasEnvConfig EnvConfig where envConfigL = id {-# INLINE envConfigL #-} @@ -1927,7 +1863,7 @@ stackRootL = configL.lens configStackRoot (\x y -> x { configStackRoot = y }) -- | The compiler specified by the @MiniBuildPlan@. This may be -- different from the actual compiler used! -wantedCompilerVersionL :: HasBuildConfigNoLocal s => Lens' s CompilerVersion +wantedCompilerVersionL :: HasBuildConfig s => Lens' s CompilerVersion wantedCompilerVersionL = miniBuildPlanL.lens mbpCompilerVersion (\x y -> x { mbpCompilerVersion = y }) @@ -1935,18 +1871,18 @@ wantedCompilerVersionL = miniBuildPlanL.lens -- | The version of the compiler which will actually be used. May be -- different than that specified in the 'MiniBuildPlan' and returned -- by 'wantedCompilerVersionL'. -actualCompilerVersionL :: HasEnvConfigNoLocal s => Lens' s CompilerVersion -actualCompilerVersionL = envConfigNoLocalL.lens +actualCompilerVersionL :: HasEnvConfig s => Lens' s CompilerVersion +actualCompilerVersionL = envConfigL.lens envConfigCompilerVersion (\x y -> x { envConfigCompilerVersion = y }) -loadedResolverL :: HasBuildConfigNoLocal s => Lens' s LoadedResolver -loadedResolverL = buildConfigNoLocalL.lens +loadedResolverL :: HasBuildConfig s => Lens' s LoadedResolver +loadedResolverL = buildConfigL.lens bcResolver (\x y -> x { bcResolver = y }) -miniBuildPlanL :: HasBuildConfigNoLocal s => Lens' s MiniBuildPlan -miniBuildPlanL = buildConfigNoLocalL.lens +miniBuildPlanL :: HasBuildConfig s => Lens' s MiniBuildPlan +miniBuildPlanL = buildConfigL.lens bcWantedMiniBuildPlan (\x y -> x { bcWantedMiniBuildPlan = y }) @@ -2003,15 +1939,10 @@ packageCachesL = configL.lens configPackageCaches (\x y -> x { configPackageCach configUrlsL :: HasConfig env => Lens' env Urls configUrlsL = configL.lens configUrls (\x y -> x { configUrls = y }) -cabalVersionL :: HasEnvConfigNoLocal env => Lens' env Version -cabalVersionL = envConfigNoLocalL.lens +cabalVersionL :: HasEnvConfig env => Lens' env Version +cabalVersionL = envConfigL.lens envConfigCabalVersion (\x y -> x { envConfigCabalVersion = y }) whichCompilerL :: Getting r CompilerVersion WhichCompiler whichCompilerL = to whichCompiler - -buildConfigL :: HasBuildConfig env => Getting r env BuildConfig -buildConfigL = to $ \env -> BuildConfig - (view buildConfigNoLocalL env) - (view buildConfigLocalL env) diff --git a/src/Stack/Types/Internal.hs b/src/Stack/Types/Internal.hs index af647f126e..54e8e472aa 100644 --- a/src/Stack/Types/Internal.hs +++ b/src/Stack/Types/Internal.hs @@ -38,12 +38,8 @@ instance HasGHCVariant config => HasGHCVariant (Env config) where ghcVariantL = envConfL.ghcVariantL instance HasConfig config => HasConfig (Env config) where configL = envConfL.configL -instance HasBuildConfigNoLocal config => HasBuildConfigNoLocal (Env config) where - buildConfigNoLocalL = envConfL.buildConfigNoLocalL instance HasBuildConfig config => HasBuildConfig (Env config) where - buildConfigLocalL = envConfL.buildConfigLocalL -instance HasEnvConfigNoLocal config => HasEnvConfigNoLocal (Env config) where - envConfigNoLocalL = envConfL.envConfigNoLocalL + buildConfigL = envConfL.buildConfigL instance HasEnvConfig config => HasEnvConfig (Env config) where envConfigL = envConfL.envConfigL diff --git a/src/test/Stack/ConfigSpec.hs b/src/test/Stack/ConfigSpec.hs index fdfa579c23..502cacd491 100644 --- a/src/test/Stack/ConfigSpec.hs +++ b/src/test/Stack/ConfigSpec.hs @@ -132,8 +132,8 @@ spec = beforeAll setup $ do LoadConfig{..} <- loadConfig' BuildConfig{..} <- loadBuildConfigRest (lcLoadBuildConfig Nothing) - bcStackYaml bcLocal `shouldBe` dir stackDotYaml - parent (bcStackYaml bcLocal)`shouldBe` dir + bcStackYaml `shouldBe` dir stackDotYaml + parent bcStackYaml `shouldBe` dir it "STACK_YAML can be relative" $ inTempDir $ do parentDir <- getCurrentDirectory >>= parseAbsDir @@ -146,7 +146,7 @@ spec = beforeAll setup $ do LoadConfig{..} <- loadConfig' BuildConfig{..} <- loadBuildConfigRest (lcLoadBuildConfig Nothing) - bcStackYaml bcLocal `shouldBe` yamlAbs + bcStackYaml `shouldBe` yamlAbs describe "defaultConfigYaml" $ it "is parseable" $ \_ -> do