-
Notifications
You must be signed in to change notification settings - Fork 846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simple refactoring #5926
Simple refactoring #5926
Changes from all commits
57ea2c2
e5cd15f
9e62fe6
e1d7e02
6073f96
d71a79c
7e1b41a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,25 +315,13 @@ loadLocalPackage pp = do | |
{ packageConfigEnableTests = not $ Set.null tests | ||
, packageConfigEnableBenchmarks = not $ Set.null benches | ||
} | ||
testconfig = config | ||
{ packageConfigEnableTests = True | ||
, packageConfigEnableBenchmarks = False | ||
} | ||
benchconfig = config | ||
{ packageConfigEnableTests = False | ||
, packageConfigEnableBenchmarks = True | ||
} | ||
Comment on lines
-318
to
-325
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my benefit, could you explain further why these can be safely deleted? I am not across the architectural considerations and would appreciate some help in understanding them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly I don't know why it existed in the first place, as it's never been used as far as I know. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fields have been there for a very long time (7+ years) and I don't know at which point they stopped being used. |
||
|
||
-- We resolve the package in 4 different configurations: | ||
-- We resolve the package in 2 different configurations: | ||
-- | ||
-- - pkg doesn't have tests or benchmarks enabled. | ||
-- | ||
-- - btpkg has them enabled if they are present. | ||
-- | ||
-- - testpkg has tests enabled, but not benchmarks. | ||
-- | ||
-- - benchpkg has benchmarks enabled, but not tests. | ||
-- | ||
-- The latter two configurations are used to compute the deps | ||
-- when --enable-benchmarks or --enable-tests are configured. | ||
-- This allows us to do an optimization where these are passed | ||
|
@@ -343,8 +331,6 @@ loadLocalPackage pp = do | |
btpkg | ||
| Set.null tests && Set.null benches = Nothing | ||
| otherwise = Just (resolvePackage btconfig gpkg) | ||
testpkg = resolvePackage testconfig gpkg | ||
benchpkg = resolvePackage benchconfig gpkg | ||
|
||
componentFiles <- memoizeRefWith $ fst <$> getPackageFilesForTargets pkg (ppCabalFP pp) nonLibComponents | ||
|
||
|
@@ -372,8 +358,6 @@ loadLocalPackage pp = do | |
|
||
pure LocalPackage | ||
{ lpPackage = pkg | ||
, lpTestDeps = dvVersionRange <$> packageDeps testpkg | ||
, lpBenchDeps = dvVersionRange <$> packageDeps benchpkg | ||
, lpTestBench = btpkg | ||
, lpComponentFiles = componentFiles | ||
, lpBuildHaddocks = cpHaddocks (ppCommon pp) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
|
||
module Stack.Types.Dependency | ||
(DepValue(..) | ||
,DepType(..) | ||
) | ||
where | ||
|
||
import Stack.Prelude | ||
import Distribution.Types.VersionRange (VersionRange) | ||
import Stack.Types.Version (intersectVersionRanges) | ||
|
||
|
||
-- | The value for a map from dependency name. This contains both the | ||
-- version range and the type of dependency, and provides a semigroup | ||
-- instance. | ||
data DepValue = DepValue | ||
{ dvVersionRange :: !VersionRange | ||
, dvType :: !DepType | ||
} | ||
deriving (Show, Typeable) | ||
instance Semigroup DepValue where | ||
DepValue a x <> DepValue b y = DepValue (intersectVersionRanges a b) (x <> y) | ||
|
||
-- | Is this package being used as a library, or just as a build tool? | ||
-- If the former, we need to ensure that a library actually | ||
-- exists. See | ||
-- <https://github.com/commercialhaskell/stack/issues/2195> | ||
data DepType = AsLibrary | AsBuildTool | ||
deriving (Show, Eq) | ||
instance Semigroup DepType where | ||
AsLibrary <> _ = AsLibrary | ||
AsBuildTool <> x = x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not follow what prompted this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was motivated by a simplified tracking of what is used from the Package type (as I intend to change this type to have a more cabal-like structure as stated in the issue, and thus I have to know what is used where). It's not strictly necessary, but I believe RecordWildCards is a bad and unnecessary extension (especially in this case, when 10+ fields are used it's questionable but obviously unseful).