-
Notifications
You must be signed in to change notification settings - Fork 701
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
default-package-bounds
(RFC #9569) implementation
#9570
Closed
jasagredo
wants to merge
7
commits into
haskell:master
from
jasagredo:jasagredo/default-pakage-bounds
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7e5be40
Extend GPD with default-package-bounds
jasagredo de41943
Use default-package-bounds in solver and in finalizePD
jasagredo c2aaf71
Use default-package-bounds in check and cabal-install
jasagredo b2e828f
Document default-package-bounds
jasagredo 0f17eff
Fix tests for default-package-bounds
jasagredo cef49cd
Apply review suggestions
jasagredo d1d698a
Fix tests
jasagredo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{-# LANGUAGE DeriveDataTypeable #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
|
||
module Distribution.Types.DefaultBounds | ||
( DefaultBounds (..) | ||
, applyDefaultBoundsToCondTree | ||
, emptyDefaultBounds | ||
) where | ||
|
||
import Distribution.Compat.Lens | ||
import Distribution.Compat.Prelude | ||
|
||
import qualified Distribution.Types.BuildInfo.Lens as L | ||
import Distribution.Types.CondTree | ||
import Distribution.Types.Dependency | ||
import Distribution.Types.ExeDependency | ||
import Distribution.Types.VersionRange | ||
|
||
data DefaultBounds = DefaultBounds | ||
{ defaultTargetBuildDepends :: [Dependency] | ||
, defaultBuildToolDepends :: [ExeDependency] | ||
} | ||
deriving (Generic, Read, Show, Eq, Data, Typeable) | ||
|
||
instance Binary DefaultBounds | ||
instance Structured DefaultBounds | ||
instance NFData DefaultBounds where rnf = genericRnf | ||
|
||
emptyDefaultBounds :: DefaultBounds | ||
emptyDefaultBounds = DefaultBounds [] [] | ||
|
||
applyDefaultBoundsToCondTree | ||
:: L.HasBuildInfo a | ||
=> DefaultBounds | ||
-> CondTree cv [Dependency] a | ||
-> CondTree cv [Dependency] a | ||
applyDefaultBoundsToCondTree db = | ||
mapTreeData (applyDefaultBoundsToBuildInfo db) | ||
. mapTreeConstrs (applyDefaultBoundsToDependencies db) | ||
|
||
applyDefaultBoundsToBuildInfo :: L.HasBuildInfo a => DefaultBounds -> a -> a | ||
applyDefaultBoundsToBuildInfo db bi = | ||
bi | ||
& L.targetBuildDepends %~ applyDefaultBoundsToDependencies db | ||
& L.buildToolDepends %~ applyDefaultBoundsToExeDependencies db | ||
|
||
applyDefaultBoundsToDependencies :: DefaultBounds -> [Dependency] -> [Dependency] | ||
applyDefaultBoundsToDependencies (DefaultBounds [] _) = id | ||
applyDefaultBoundsToDependencies (DefaultBounds bd _) = | ||
map | ||
( \dep@(Dependency pkg vorig l) -> | ||
if isAnyVersion vorig | ||
then maybe dep (\v -> Dependency pkg (depVerRange v) l) $ find ((pkg ==) . depPkgName) bd | ||
else dep | ||
) | ||
|
||
applyDefaultBoundsToExeDependencies :: DefaultBounds -> [ExeDependency] -> [ExeDependency] | ||
applyDefaultBoundsToExeDependencies (DefaultBounds _ []) = id | ||
applyDefaultBoundsToExeDependencies (DefaultBounds _ btd) = | ||
map | ||
( \dep@(ExeDependency pkg comp vorig) -> | ||
if isAnyVersion vorig | ||
then maybe dep (ExeDependency pkg comp . exeDepVerRange) $ find (\(ExeDependency pkg' comp' _) -> pkg == pkg' && comp == comp') btd | ||
else dep | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Distribution.Types.DefaultBounds.Lens | ||
( DefaultBounds | ||
, module Distribution.Types.DefaultBounds.Lens | ||
) where | ||
|
||
import Distribution.Compat.Lens | ||
import Distribution.Compat.Prelude | ||
import Prelude () | ||
|
||
import qualified Distribution.Types.DefaultBounds as T | ||
|
||
import Distribution.Types.DefaultBounds (DefaultBounds) | ||
import Distribution.Types.Dependency (Dependency) | ||
import Distribution.Types.ExeDependency (ExeDependency) | ||
|
||
------------------------------------------------------------------------------- | ||
-- GenericPackageDescription | ||
------------------------------------------------------------------------------- | ||
|
||
defaultTargetBuildDepends :: Lens' DefaultBounds [Dependency] | ||
defaultTargetBuildDepends f s = fmap (\x -> s{T.defaultTargetBuildDepends = x}) (f (T.defaultTargetBuildDepends s)) | ||
{-# INLINE defaultTargetBuildDepends #-} | ||
|
||
defaultBuildToolDepends :: Lens' DefaultBounds [ExeDependency] | ||
defaultBuildToolDepends f s = fmap (\x -> s{T.defaultBuildToolDepends = x}) (f (T.defaultBuildToolDepends s)) | ||
{-# INLINE defaultBuildToolDepends #-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.