Skip to content

Commit

Permalink
Merge pull request #6104 from commercialhaskell/fix2407-5
Browse files Browse the repository at this point in the history
Fix #2407 Refactor Stack.Types.Config and Stack.Types.Config.Build
  • Loading branch information
mpilgrem authored Apr 19, 2023
2 parents 5ddd9e8 + 4e590bf commit f317632
Show file tree
Hide file tree
Showing 38 changed files with 215 additions and 195 deletions.
4 changes: 3 additions & 1 deletion package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ library:
- Stack.Types.ApplyGhcOptions
- Stack.Types.Build
- Stack.Types.BuildConfig
- Stack.Types.BuildOpts
- Stack.Types.CabalConfigKey
- Stack.Types.ColorWhen
- Stack.Types.CompilerBuild
- Stack.Types.CompilerPaths
- Stack.Types.Compiler
- Stack.Types.Config
- Stack.Types.Config.Build
- Stack.Types.Config.Exception
- Stack.Types.ConfigMonoid
- Stack.Types.Curator
Expand All @@ -282,6 +282,7 @@ library:
- Stack.Types.DumpPackage
- Stack.Types.EnvConfig
- Stack.Types.EnvSettings
- Stack.Types.ExtraDirs
- Stack.Types.GHCDownloadInfo
- Stack.Types.GHCVariant
- Stack.Types.GhcOptionKey
Expand All @@ -296,6 +297,7 @@ library:
- Stack.Types.PackageName
- Stack.Types.Platform
- Stack.Types.Project
- Stack.Types.ProjectAndConfigMonoid
- Stack.Types.ProjectConfig
- Stack.Types.PvpBounds
- Stack.Types.Resolver
Expand Down
14 changes: 8 additions & 6 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,24 @@ import Stack.Types.Build
, TaskType (..), taskLocation
)
import Stack.Types.BuildConfig ( HasBuildConfig, stackYamlL )
import Stack.Types.BuildOpts
( BuildCommand (..), BuildOpts (..), BuildOptsCLI (..)
, FileWatchOpts (..), buildOptsMonoidBenchmarksL
, buildOptsMonoidHaddockL, buildOptsMonoidInstallExesL
, buildOptsMonoidTestsL
)
import Stack.Types.Compiler ( getGhcVersion )
import Stack.Types.CompilerPaths ( cabalVersionL )
import Stack.Types.Config
( BuildOpts (..), BuildOptsCLI (..), Config (..)
, HasConfig (..), buildOptsL, buildOptsMonoidBenchmarksL
, buildOptsMonoidHaddockL, buildOptsMonoidInstallExesL
, buildOptsMonoidTestsL, globalOptsBuildOptsMonoidL
( Config (..), HasConfig (..), buildOptsL
)
import Stack.Types.Config.Build
( BuildCommand (..), FileWatchOpts (..) )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), HasSourceMap
, actualCompilerVersionL, installationRootDeps
, installationRootLocal, packageDatabaseDeps
, packageDatabaseExtra, packageDatabaseLocal
)
import Stack.Types.GlobalOpts ( globalOptsBuildOptsMonoidL )
import Stack.Types.NamedComponent ( exeComponents )
import Stack.Types.Package
( InstallLocation (..), LocalPackage (..), Package (..)
Expand Down
7 changes: 3 additions & 4 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ import Stack.Types.Build
)
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), stackYamlL )
import Stack.Types.BuildOpts
( BuildOpts (..), BuildOptsCLI (..), BuildSubset (..) )
import Stack.Types.Compiler ( WhichCompiler (..) )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..) )
import Stack.Types.Config
( BuildOpts (..), BuildOptsCLI (..), BuildSubset (..)
, Config (..), HasConfig (..), stackRootL
)
import Stack.Types.Config ( Config (..), HasConfig (..), stackRootL )
import Stack.Types.Curator ( Curator (..) )
import Stack.Types.Dependency
( DepValue (DepValue), DepType (AsLibrary) )
Expand Down
12 changes: 6 additions & 6 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,20 @@ import Stack.Types.Build
)
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), projectRootL )
import Stack.Types.BuildOpts
( BenchmarkOpts (..), BuildOpts (..), BuildOptsCLI (..)
, CabalVerbosity (..), HaddockOpts (..), TestOpts (..)
)
import Stack.Types.Compiler
( ActualCompiler (..), WhichCompiler (..)
, compilerVersionString, getGhcVersion
, compilerVersionString, getGhcVersion, whichCompilerL
)
import Stack.Types.CompilerPaths
( CompilerPaths (..), GhcPkgExe (..), HasCompiler (..)
, cabalVersionL, cpWhich, getCompilerPath, getGhcPkgExe
)
import Stack.Types.Config
( BenchmarkOpts (..), BuildOpts (..), BuildOptsCLI (..)
, CabalVerbosity (..), Config (..), HaddockOpts (..)
, HasConfig (..), TestOpts (..), buildOptsL, stackRootL
, whichCompilerL
)
( Config (..), HasConfig (..), buildOptsL, stackRootL )
import Stack.Types.DumpLogs ( DumpLogs (..) )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.EnvConfig
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Build/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Stack.Prelude
import Stack.Types.Build ( BaseConfigOpts (..), BuildException (..) )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..) )
import Stack.Types.Config
import Stack.Types.BuildOpts
( BuildOpts (..), BuildOptsCLI (..), HaddockOpts (..) )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.GhcPkgId ( GhcPkgId )
Expand Down
9 changes: 5 additions & 4 deletions src/Stack/Build/Source.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ import Stack.Types.ApplyGhcOptions ( ApplyGhcOptions (..) )
import Stack.Types.Build ( FlagSource (..) )
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..) )
import Stack.Types.CabalConfigKey ( CabalConfigKey (..) )
import Stack.Types.CompilerPaths ( HasCompiler, getCompilerPath )
import Stack.Types.Config
import Stack.Types.BuildOpts
( ApplyCLIFlag (..), BuildOpts (..), BuildOptsCLI (..)
, Config (..), HasConfig (..), TestOpts (..), buildOptsL
, TestOpts (..)
)
import Stack.Types.CabalConfigKey ( CabalConfigKey (..) )
import Stack.Types.CompilerPaths ( HasCompiler, getCompilerPath )
import Stack.Types.Config ( Config (..), HasConfig (..), buildOptsL )
import Stack.Types.Curator ( Curator (..) )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), HasSourceMap (..)
Expand Down
3 changes: 2 additions & 1 deletion src/Stack/Build/Target.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ import Stack.SourceMap ( additionalDepPackage )
import Stack.Prelude
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..) )
import Stack.Types.Config ( BuildOptsCLI (..), Config (..) )
import Stack.Types.BuildOpts ( BuildOptsCLI (..) )
import Stack.Types.Config ( Config (..) )
import Stack.Types.NamedComponent
( NamedComponent (..), renderComponent )
import Stack.Types.Build ( BuildPrettyException (..) )
Expand Down
12 changes: 7 additions & 5 deletions src/Stack/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,12 @@ import Stack.Types.AllowNewerDeps ( AllowNewerDeps (..) )
import Stack.Types.ApplyGhcOptions ( ApplyGhcOptions (..) )
import Stack.Types.Build ( BuildException (..), FlagSource (..) )
import Stack.Types.BuildConfig ( BuildConfig (..) )
import Stack.Types.BuildOpts ( BuildOpts (..) )
import Stack.Types.ColorWhen ( ColorWhen (..) )
import Stack.Types.Compiler ( defaultCompilerRepository )
import Stack.Types.Config
( BuildOpts (..), Config (..), HasConfig (..)
, ProjectAndConfigMonoid (..), askLatestSnapshotUrl
, configProjectRoot, parseProjectAndConfigMonoid
, platformOnlyRelDir, stackRootL, workDirL
( Config (..), HasConfig (..), askLatestSnapshotUrl
, configProjectRoot, stackRootL, workDirL
)
import Stack.Types.Config.Exception
( ConfigException (..), ConfigPrettyException (..)
Expand All @@ -118,8 +117,11 @@ import Stack.Types.Docker ( DockerOptsMonoid (..), dockerEnable )
import Stack.Types.DumpLogs ( DumpLogs (..) )
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import Stack.Types.Nix ( nixEnable )
import Stack.Types.Platform ( PlatformVariant (..) )
import Stack.Types.Platform
( PlatformVariant (..), platformOnlyRelDir )
import Stack.Types.Project ( Project (..) )
import Stack.Types.ProjectAndConfigMonoid
( ProjectAndConfigMonoid (..), parseProjectAndConfigMonoid )
import Stack.Types.ProjectConfig ( ProjectConfig (..) )
import Stack.Types.PvpBounds ( PvpBounds (..), PvpBoundsType (..) )
import Stack.Types.Resolver ( AbstractResolver (..), Snapshots (..) )
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Config/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module Stack.Config.Build

import Distribution.Verbosity ( normal )
import Stack.Prelude
import Stack.Types.Config
import Stack.Types.BuildOpts
( BenchmarkOpts (..), BenchmarkOptsMonoid (..)
, BuildOpts (..), BuildOptsMonoid (..), CabalVerbosity (..)
, HaddockOpts (..), HaddockOptsMonoid (..), TestOpts (..)
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Coverage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..) )
import Stack.Types.Compiler ( getGhcVersion )
import Stack.Types.CompilerPaths ( cabalVersionL )
import Stack.Types.Config ( BuildOptsCLI (..), defaultBuildOptsCLI )
import Stack.Types.BuildOpts ( BuildOptsCLI (..), defaultBuildOptsCLI )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL
, hpcReportDir
Expand Down
9 changes: 7 additions & 2 deletions src/Stack/Dot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ import Stack.SourceMap
import Stack.Types.Build
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..) )
import Stack.Types.BuildOpts
( ApplyCLIFlag, BuildOptsCLI (..), buildOptsMonoidBenchmarksL
, buildOptsMonoidTestsL, defaultBuildOptsCLI
)
import Stack.Types.Compiler ( wantedToActual )
import Stack.Types.Config
import Stack.Types.Config ( HasConfig (..) )
import Stack.Types.DumpPackage ( DumpPackage (..) )
import Stack.Types.EnvConfig ( EnvConfig (..), HasSourceMap (..) )
import Stack.Types.GHCVariant ( HasGHCVariant (..) )
import Stack.Types.GhcPkgId
import Stack.Types.GlobalOpts ( globalOptsBuildOptsMonoidL )
import Stack.Types.Platform ( HasPlatform (..) )
import Stack.Types.Runner ( HasRunner (..), Runner )
import Stack.Types.Runner ( HasRunner (..), Runner, globalOptsL )
import Stack.Types.SourceMap

-- | Type representing exceptions thrown by functions exported by the
Expand Down
7 changes: 3 additions & 4 deletions src/Stack/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import Stack.Prelude
import Stack.Runners ( ShouldReexec (..), withConfig, withEnvConfig )
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..) )
import Stack.Types.BuildOpts
( BuildOptsCLI (..), defaultBuildOptsCLI )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..), getGhcPkgExe )
import Stack.Types.Config
( BuildOptsCLI (..), Config (..), HasConfig (..)
, defaultBuildOptsCLI
)
import Stack.Types.Config ( Config (..), HasConfig (..) )
import Stack.Types.EnvConfig ( EnvConfig )
import Stack.Types.EnvSettings ( EnvSettings (..) )
import Stack.Types.Runner ( Runner )
Expand Down
7 changes: 3 additions & 4 deletions src/Stack/Ghci.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ import Stack.Runners ( ShouldReexec (..), withConfig, withEnvConfig )
import Stack.Types.Build
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), stackYamlL )
import Stack.Types.BuildOpts
( ApplyCLIFlag, BuildOptsCLI (..), defaultBuildOptsCLI )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..) )
import Stack.Types.Config
( ApplyCLIFlag, BuildOptsCLI (..), Config (..)
, HasConfig (..), buildOptsL, defaultBuildOptsCLI
)
import Stack.Types.Config ( Config (..), HasConfig (..), buildOptsL )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL
, shaPathForBytes
Expand Down
12 changes: 7 additions & 5 deletions src/Stack/Hoogle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ import Stack.Runners
( ShouldReexec (..), withConfig, withDefaultEnvConfig
, withEnvConfig
)
import Stack.Types.Config
( BuildOptsCLI (..), Config (..), HasConfig (..)
, buildOptsMonoidHaddockL, defaultBuildOptsCLI
, globalOptsBuildOptsMonoidL
import Stack.Types.BuildOpts
( BuildOptsCLI (..), buildOptsMonoidHaddockL
, defaultBuildOptsCLI
)
import Stack.Types.Config
( Config (..), HasConfig (..) )
import Stack.Types.EnvConfig
( EnvConfig, HasSourceMap (..), hoogleDatabasePath
, hoogleRoot
)
import Stack.Types.EnvSettings ( EnvSettings (..) )
import Stack.Types.GlobalOpts ( GlobalOpts (..) )
import Stack.Types.GlobalOpts
( GlobalOpts (..), globalOptsBuildOptsMonoidL )
import Stack.Types.Runner ( Runner, globalOptsL )
import Stack.Types.SourceMap ( DepPackage (..), SourceMap (..) )

Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Options/BenchParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Options.Applicative
import Options.Applicative.Builder.Extra ( optionalFirst )
import Stack.Prelude
import Stack.Options.Utils ( hideMods )
import Stack.Types.Config ( BenchmarkOptsMonoid (..) )
import Stack.Types.BuildOpts ( BenchmarkOptsMonoid (..) )

-- | Parser for bench arguments.
-- FIXME hiding options
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Options/BuildMonoidParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import Stack.Options.BenchParser ( benchOptsParser )
import Stack.Options.TestParser ( testOptsParser )
import Stack.Options.HaddockParser ( haddockOptsParser )
import Stack.Options.Utils ( GlobalOptsContext (..), hideMods )
import Stack.Types.Config.Build
import Stack.Types.BuildOpts
( BuildOptsMonoid (..), CabalVerbosity
, toFirstCabalVerbosity
)
Expand Down
6 changes: 5 additions & 1 deletion src/Stack/Options/BuildParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import Options.Applicative.Builder.Extra
import Stack.Options.Completion
import Stack.Options.PackageParser ( readFlag )
import Stack.Prelude
import Stack.Types.Config
import Stack.Types.BuildOpts
( ApplyCLIFlag, BuildCommand, BuildOptsCLI (..)
, BuildSubset (..), FileWatchOpts (..)
)
import Stack.Types.Config ()

-- | Parser for CLI-only build arguments
buildOptsParser :: BuildCommand
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Options/HaddockParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Options.Applicative ( Parser, help, long, metavar )
import Options.Applicative.Args ( argsOption )
import Stack.Options.Utils ( hideMods )
import Stack.Prelude
import Stack.Types.Config ( HaddockOptsMonoid (..) )
import Stack.Types.BuildOpts ( HaddockOptsMonoid (..) )

-- | Parser for haddock arguments.
haddockOptsParser :: Bool -> Parser HaddockOptsMonoid
Expand Down
2 changes: 1 addition & 1 deletion src/Stack/Options/PackageParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import qualified Data.Map as Map
import Options.Applicative ( ReadM, readerError )
import Options.Applicative.Types ( readerAsk )
import Stack.Prelude
import Stack.Types.Config.Build ( ApplyCLIFlag (..) )
import Stack.Types.BuildOpts ( ApplyCLIFlag (..) )

-- | Parser for package:[-]flag
readFlag :: ReadM (Map ApplyCLIFlag (Map FlagName Bool))
Expand Down
3 changes: 2 additions & 1 deletion src/Stack/Options/TestParser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import Options.Applicative.Args
import Options.Applicative.Builder.Extra
import Stack.Options.Utils
import Stack.Prelude
import Stack.Types.Config
import Stack.Types.BuildOpts ( TestOptsMonoid (..) )
import Stack.Types.Config ()

-- | Parser for test arguments.
-- FIXME hide args
Expand Down
5 changes: 3 additions & 2 deletions src/Stack/Path.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), projectRootL
, stackYamlL
)
import Stack.Types.BuildOpts ( buildOptsMonoidHaddockL )
import Stack.Types.CompilerPaths
( CompilerPaths (..), HasCompiler (..), getCompilerPath )
import Stack.Types.Config
( Config (..), HasConfig (..), buildOptsMonoidHaddockL
, globalOptsBuildOptsMonoidL, stackGlobalConfigL, stackRootL
( Config (..), HasConfig (..), stackGlobalConfigL, stackRootL
)
import Stack.Types.EnvConfig
( EnvConfig, HasEnvConfig (..), bindirCompilerTools
Expand All @@ -41,6 +41,7 @@ import Stack.Types.EnvConfig
, packageDatabaseExtra, packageDatabaseLocal
)
import Stack.Types.GHCVariant ( HasGHCVariant (..) )
import Stack.Types.GlobalOpts ( globalOptsBuildOptsMonoidL )
import Stack.Types.Platform ( HasPlatform (..) )
import Stack.Types.Runner ( HasRunner (..), Runner, globalOptsL )
import qualified System.FilePath as FP
Expand Down
5 changes: 3 additions & 2 deletions src/Stack/Runners.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ import qualified Stack.Nix as Nix
import Stack.Prelude
import Stack.Setup ( setupEnv )
import Stack.Storage.User ( logUpgradeCheck, upgradeChecksSince )
import Stack.Types.BuildOpts
( BuildOptsCLI, defaultBuildOptsCLI )
import Stack.Types.ColorWhen ( ColorWhen (..) )
import Stack.Types.Config
( BuildOptsCLI, Config (..), defaultBuildOptsCLI )
import Stack.Types.Config ( Config (..) )
import Stack.Types.ConfigMonoid ( ConfigMonoid (..) )
import Stack.Types.Docker ( dockerEnable )
import Stack.Types.EnvConfig ( EnvConfig )
Expand Down
7 changes: 3 additions & 4 deletions src/Stack/SDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ import Stack.Types.Build
)
import Stack.Types.BuildConfig
( BuildConfig (..), HasBuildConfig (..), stackYamlL )
import Stack.Types.Config
( BuildOpts (..), Config (..), HasConfig (..)
, defaultBuildOpts, defaultBuildOptsCLI
)
import Stack.Types.BuildOpts
( BuildOpts (..), defaultBuildOpts, defaultBuildOptsCLI )
import Stack.Types.Config ( Config (..), HasConfig (..) )
import Stack.Types.EnvConfig
( EnvConfig (..), HasEnvConfig (..), actualCompilerVersionL )
import Stack.Types.GhcPkgId ( GhcPkgId )
Expand Down
Loading

0 comments on commit f317632

Please sign in to comment.