diff --git a/cabal-install/src/Distribution/Client/Configure.hs b/cabal-install/src/Distribution/Client/Configure.hs index 326ea5e802b..1538457b7f2 100644 --- a/cabal-install/src/Distribution/Client/Configure.hs +++ b/cabal-install/src/Distribution/Client/Configure.hs @@ -377,13 +377,13 @@ checkConfigExFlags verbosity installedPkgIndex sourcePkgIndex flags = do for_ (safeHead unknownPreferences) $ \h -> warn verbosity $ "Preference refers to an unknown package: " - ++ showWithConstraintSource prettyShow h + ++ prettyShow h where unknownConstraints = filter (unknown . userConstraintPackageName . constraintInner) $ configExConstraints flags unknownPreferences = - filter (unknown . (\(PackageVersionConstraint name _) -> name) . constraintInner) $ + filter (unknown . (\(PackageVersionConstraint name _) -> name)) $ configPreferences flags unknown pkg = null (PackageIndex.lookupPackageName installedPkgIndex pkg) @@ -443,7 +443,7 @@ planLocalPackage . addPreferences -- preferences from the config file or command line [ PackageVersionPreference name ver - | PackageVersionConstraint name ver <- map constraintInner $ configPreferences configExFlags + | PackageVersionConstraint name ver <- configPreferences configExFlags ] . addConstraints -- version constraints from the config file or command line diff --git a/cabal-install/src/Distribution/Client/Install.hs b/cabal-install/src/Distribution/Client/Install.hs index 7fd751d6014..206a15320fc 100644 --- a/cabal-install/src/Distribution/Client/Install.hs +++ b/cabal-install/src/Distribution/Client/Install.hs @@ -624,7 +624,7 @@ planPackages . addPreferences -- preferences from the config file or command line [ PackageVersionPreference name ver - | PackageVersionConstraint name ver <- map constraintInner $ configPreferences configExFlags + | PackageVersionConstraint name ver <- configPreferences configExFlags ] . addConstraints -- version constraints from the config file or command line diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs index 5a75f9f9931..60166ca9c32 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs @@ -1430,10 +1430,8 @@ legacySharedConfigFieldDescrs constraintSrc = (\v conf -> conf{configExConstraints = v}) , commaNewLineListFieldParsec "preferences" - (pretty . constraintInner) - ( (\preference -> WithConstraintSource{constraintInner = preference, constraintSource = constraintSrc}) - `fmap` parsec - ) + pretty + parsec configPreferences (\v conf -> conf{configPreferences = v}) , monoidFieldParsec diff --git a/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs b/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs index 066b390239d..847659ddc33 100644 --- a/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs +++ b/cabal-install/src/Distribution/Client/ProjectConfig/Types.hs @@ -208,7 +208,7 @@ data ProjectConfigShared = ProjectConfigShared , projectConfigStoreDir :: Flag FilePath , -- solver configuration projectConfigConstraints :: [WithConstraintSource UserConstraint] - , projectConfigPreferences :: [WithConstraintSource PackageVersionConstraint] + , projectConfigPreferences :: [PackageVersionConstraint] , projectConfigCabalVersion :: Flag Version -- TODO: [required eventually] unused , projectConfigSolver :: Flag PreSolver , projectConfigAllowOlder :: Maybe AllowOlder @@ -411,7 +411,7 @@ data SolverSettings = SolverSettings -- ^ Available Hackage servers. , solverSettingLocalNoIndexRepos :: [LocalRepo] , solverSettingConstraints :: [WithConstraintSource UserConstraint] - , solverSettingPreferences :: [WithConstraintSource PackageVersionConstraint] + , solverSettingPreferences :: [PackageVersionConstraint] , solverSettingFlagAssignment :: FlagAssignment -- ^ For all local packages , solverSettingFlagAssignments :: Map PackageName FlagAssignment diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 731f3d95c1b..26fc270b5e9 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -1299,7 +1299,7 @@ planPackages . addPreferences -- preferences from the config file or command line [ PackageVersionPreference name ver - | PackageVersionConstraint name ver <- map constraintInner solverSettingPreferences + | PackageVersionConstraint name ver <- solverSettingPreferences ] . addConstraints -- version constraints from the config file or command line diff --git a/cabal-install/src/Distribution/Client/Sandbox/PackageEnvironment.hs b/cabal-install/src/Distribution/Client/Sandbox/PackageEnvironment.hs index b3bdde5704a..b33da2142f9 100644 --- a/cabal-install/src/Distribution/Client/Sandbox/PackageEnvironment.hs +++ b/cabal-install/src/Distribution/Client/Sandbox/PackageEnvironment.hs @@ -194,9 +194,7 @@ pkgEnvFieldDescrs src = , commaListFieldParsec "preferences" pretty - ( (\preference -> WithConstraintSource{constraintInner = preference, constraintSource = src}) - `fmap` parsec - ) + parsec (configPreferences . savedConfigureExFlags . pkgEnvSavedConfig) ( \v pkgEnv -> updateConfigureExFlags diff --git a/cabal-install/src/Distribution/Client/Setup.hs b/cabal-install/src/Distribution/Client/Setup.hs index af214f17eb2..81fa460954c 100644 --- a/cabal-install/src/Distribution/Client/Setup.hs +++ b/cabal-install/src/Distribution/Client/Setup.hs @@ -915,7 +915,7 @@ data ConfigExFlags = ConfigExFlags , configAppend :: Flag Bool , configBackup :: Flag Bool , configExConstraints :: [WithConstraintSource UserConstraint] - , configPreferences :: [WithConstraintSource PackageVersionConstraint] + , configPreferences :: [PackageVersionConstraint] , configSolver :: Flag PreSolver , configAllowNewer :: Maybe AllowNewer , configAllowOlder :: Maybe AllowOlder @@ -1008,11 +1008,9 @@ configureExOptions _showOrParseArgs constraint = "CONSTRAINT" ( parsecToReadE (const "dependency expected") - ( (\pkg -> [WithConstraintSource{constraintInner = pkg, constraintSource = constraint}]) - `fmap` parsec - ) + (fmap (\x -> [x]) parsec) ) - (map $ showWithConstraintSource prettyShow) + (map prettyShow) ) , optionSolver configSolver (\v flags -> flags{configSolver = v}) , option diff --git a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs b/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs index 5da69680ea1..95ed974fbdc 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs @@ -620,7 +620,7 @@ instance Arbitrary ProjectConfigShared where projectConfigIndexState <- arbitrary projectConfigStoreDir <- arbitraryFlag arbitraryShortToken projectConfigConstraints <- arbitraryWithConstraintSources - projectConfigPreferences <- shortListOf 2 arbitraryWithConstraintSource + projectConfigPreferences <- shortListOf 2 arbitrary projectConfigCabalVersion <- arbitrary projectConfigSolver <- arbitrary projectConfigAllowOlder <- arbitrary