Commit 60e3a6a0 authored by Robert Henderson's avatar Robert Henderson

Renamed constructors of Qualifier and UserQualifier.

Prefixed all constructors of Qualifier with 'Qual' to make it
easier to grep them.

Renamed 'Unqualified' to 'Toplevel'.
parent ff38c921
......@@ -150,7 +150,7 @@ projectFreezeConstraints plan =
versionConstraints :: Map PackageName [(UserConstraint, ConstraintSource)]
versionConstraints =
Map.mapWithKey
(\p v -> [(UserConstraint UserUnqualified p (PackagePropertyVersion v),
(\p v -> [(UserConstraint UserToplevel p (PackagePropertyVersion v),
ConstraintSourceFreeze)])
versionRanges
......@@ -168,7 +168,7 @@ projectFreezeConstraints plan =
flagConstraints :: Map PackageName [(UserConstraint, ConstraintSource)]
flagConstraints =
Map.mapWithKey
(\p f -> [(UserConstraint UserUnqualified p (PackagePropertyFlags f),
(\p f -> [(UserConstraint UserToplevel p (PackagePropertyFlags f),
ConstraintSourceFreeze)])
flagAssignments
......
......@@ -251,7 +251,7 @@ freezePackages verbosity globalFlags pkgs = do
(pkgIdToConstraint $ packageId pkg, ConstraintSourceUserConfig userPackageEnvironmentFile)
where
pkgIdToConstraint pkgId =
UserConstraint UserUnqualified (packageName pkgId)
UserConstraint UserToplevel (packageName pkgId)
(PackagePropertyVersion $ thisVersion (packageVersion pkgId))
createPkgEnv config = mempty { pkgEnvSavedConfig = config }
showPkgEnv = BS.Char8.pack . showPackageEnvironment
......
......@@ -690,7 +690,7 @@ extraPackageNameEnv names = PackageNameEnv pkgNameLookup
-- command line.
data UserQualifier =
-- | Top-level dependency.
UserUnqualified
UserToplevel
-- | Setup dependency.
| UserSetup PackageName
......@@ -702,9 +702,9 @@ data UserQualifier =
instance Binary UserQualifier
fromUserQualifier :: UserQualifier -> Qualifier
fromUserQualifier UserUnqualified = Unqualified
fromUserQualifier (UserSetup name) = Setup name
fromUserQualifier (UserExe name1 name2) = Exe name1 name2
fromUserQualifier UserToplevel = QualToplevel
fromUserQualifier (UserSetup name) = QualSetup name
fromUserQualifier (UserExe name1 name2) = QualExe name1 name2
-- | Version of 'PackageConstraint' that the user can specify on
-- the command line.
......@@ -740,7 +740,7 @@ instance Text UserConstraint where
parse = do
-- Qualified name
pn <- parse
(qual, name) <- return (UserUnqualified, pn)
(qual, name) <- return (UserToplevel, pn)
+++
do _ <- Parse.string ":setup."
pn2 <- parse
......
......@@ -272,4 +272,4 @@ buildTree idx (IndependentGoals ind) igs =
topLevelGoal qpn = OpenGoal (Simple (Dep False {- not exe -} qpn (Constrained [])) ()) UserGoal
qpns | ind = makeIndependent igs
| otherwise = L.map (Q (PackagePath DefaultNamespace Unqualified)) igs
| otherwise = L.map (Q (PackagePath DefaultNamespace QualToplevel)) igs
......@@ -59,7 +59,7 @@ convConfId (PI (Q (PackagePath _ q) pn) (I v loc)) =
case loc of
Inst pi -> Left (PreExistingId sourceId pi)
_otherwise
| Exe _ pn' <- q
| QualExe _ pn' <- q
-- NB: the dependencies of the executable are also
-- qualified. So the way to tell if this is an executable
-- dependency is to make sure the qualifier is pointing
......
......@@ -244,9 +244,9 @@ qualifyDeps QO{..} (Q pp@(PackagePath ns q) pn) = go
goD (Lang lang) _ = Lang lang
goD (Pkg pkn vr) _ = Pkg pkn vr
goD (Dep is_exe dep ci) comp
| is_exe = Dep is_exe (Q (PackagePath ns (Exe pn dep)) dep) (fmap (Q pp) ci)
| qBase dep = Dep is_exe (Q (PackagePath ns (Base pn)) dep) (fmap (Q pp) ci)
| qSetup comp = Dep is_exe (Q (PackagePath ns (Setup pn)) dep) (fmap (Q pp) ci)
| is_exe = Dep is_exe (Q (PackagePath ns (QualExe pn dep)) dep) (fmap (Q pp) ci)
| qBase dep = Dep is_exe (Q (PackagePath ns (QualBase pn)) dep) (fmap (Q pp) ci)
| qSetup comp = Dep is_exe (Q (PackagePath ns (QualSetup pn)) dep) (fmap (Q pp) ci)
| otherwise = Dep is_exe (Q (PackagePath ns inheritedQ) dep) (fmap (Q pp) ci)
-- If P has a setup dependency on Q, and Q has a regular dependency on R, then
......@@ -258,10 +258,10 @@ qualifyDeps QO{..} (Q pp@(PackagePath ns q) pn) = go
-- a detailed discussion.
inheritedQ :: Qualifier
inheritedQ = case q of
Setup _ -> q
Exe _ _ -> q
Unqualified -> q
Base _ -> Unqualified
QualSetup _ -> q
QualExe _ _ -> q
QualToplevel -> q
QualBase _ -> QualToplevel
-- Should we qualify this goal with the 'Base' package path?
qBase :: PN -> Bool
......
......@@ -88,22 +88,22 @@ instI _ = False
primaryPP :: PackagePath -> Bool
primaryPP (PackagePath _ns q) = go q
where
go Unqualified = True
go (Base _) = True
go (Setup _) = False
go (Exe _ _) = False
go QualToplevel = True
go (QualBase _) = True
go (QualSetup _) = False
go (QualExe _ _) = False
-- | Is the package a dependency of a setup script. This is used to
-- establish whether or not certain constraints should apply to this
-- dependency (grep 'setupPP' to see the use sites).
--
setupPP :: PackagePath -> Bool
setupPP (PackagePath _ns (Setup _)) = True
setupPP (PackagePath _ns (QualSetup _)) = True
setupPP (PackagePath _ns _) = False
-- | Create artificial parents for each of the package names, making
-- them all independent.
makeIndependent :: [PN] -> [QPN]
makeIndependent ps = [ Q pp pn | (pn, i) <- zip ps [0::Int ..]
, let pp = PackagePath (Independent i) Unqualified
, let pp = PackagePath (Independent i) QualToplevel
]
......@@ -348,8 +348,8 @@ deferSetupChoices = trav go
go x = x
noSetup :: Goal QPN -> Bool
noSetup (Goal (P (Q (PackagePath _ns (Setup _)) _)) _) = False
noSetup _ = True
noSetup (Goal (P (Q (PackagePath _ns (QualSetup _)) _)) _) = False
noSetup _ = True
-- | Transformation that tries to avoid making weak flag choices early.
-- Weak flags are trivial flags (not influencing dependencies) or such
......
......@@ -231,5 +231,5 @@ _removeGR = trav go
dummy :: QGoalReason
dummy = PDependency
$ PI (Q (PackagePath DefaultNamespace Unqualified) (mkPackageName "$"))
$ PI (Q (PackagePath DefaultNamespace QualToplevel) (mkPackageName "$"))
(I (mkVersion [1]) InRepo)
......@@ -46,7 +46,7 @@ instance Binary ConstraintScope
-- the package with the specified name when that package is a
-- top-level dependency in the default namespace.
scopeToplevel :: PackageName -> ConstraintScope
scopeToplevel = ScopeQualified . Q (PackagePath DefaultNamespace Unqualified)
scopeToplevel = ScopeQualified . Q (PackagePath DefaultNamespace QualToplevel)
-- | Returns the package name associated with a constraint scope.
scopeToPackageName :: ConstraintScope -> PackageName
......
......@@ -49,12 +49,12 @@ dispNamespace (Independent i) = Disp.int i <<>> Disp.text "."
-- | Qualifier of a package within a namespace (see 'PackagePath')
data Qualifier =
-- | Top-level dependency in this namespace
Unqualified
QualToplevel
-- | Any dependency on base is considered independent
--
-- This makes it possible to have base shims.
| Base PackageName
| QualBase PackageName
-- | Setup dependency
--
......@@ -63,7 +63,7 @@ data Qualifier =
-- are independent from everything else. However, this very quickly leads to
-- infinite search trees in the solver. Therefore we limit ourselves to
-- a single qualifier (within a given namespace).
| Setup PackageName
| QualSetup PackageName
-- | If we depend on an executable from a package (via
-- @build-tools@), we should solve for the dependencies of that
......@@ -75,7 +75,7 @@ data Qualifier =
-- of the depended upon executables from a package; if we
-- tracked only @pn2@, that would require us to pick only one
-- version of an executable over the entire install plan.)
| Exe PackageName PackageName
| QualExe PackageName PackageName
deriving (Eq, Ord, Show, Generic)
instance Binary Qualifier
......@@ -89,11 +89,11 @@ instance Binary Qualifier
-- is the qualifier and @"base"@ is the actual dependency (which, for the
-- 'Base' qualifier, will always be @base@).
dispQualifier :: Qualifier -> Disp.Doc
dispQualifier Unqualified = Disp.empty
dispQualifier (Setup pn) = disp pn <<>> Disp.text ":setup."
dispQualifier (Exe pn pn2) = disp pn <<>> Disp.text ":" <<>>
disp pn2 <<>> Disp.text ":exe."
dispQualifier (Base pn) = disp pn <<>> Disp.text "."
dispQualifier QualToplevel = Disp.empty
dispQualifier (QualSetup pn) = disp pn <<>> Disp.text ":setup."
dispQualifier (QualExe pn pn2) = disp pn <<>> Disp.text ":" <<>>
disp pn2 <<>> Disp.text ":exe."
dispQualifier (QualBase pn) = disp pn <<>> Disp.text "."
-- | A qualified entity. Pairs a package path with the entity.
data Qualified a = Q PackagePath a
......
......@@ -567,7 +567,7 @@ instance Arbitrary RemoteRepo where
instance Arbitrary UserConstraint where
arbitrary =
oneof [ UserConstraint UserUnqualified <$> arbitrary <*> prop
oneof [ UserConstraint UserToplevel <$> arbitrary <*> prop
| prop <- [ PackagePropertyVersion <$> arbitrary
, pure PackagePropertyInstalled
, pure PackagePropertySource
......
......@@ -29,7 +29,7 @@ readUserConstraintTest =
pkgName = "template-haskell"
constr = pkgName ++ " installed"
expected = UserConstraint UserUnqualified (mkPackageName pkgName)
expected = UserConstraint UserToplevel (mkPackageName pkgName)
PackagePropertyInstalled
actual = let (Right r) = readUserConstraint constr in r
......@@ -40,7 +40,7 @@ parseUserConstraintTest =
pkgName = "template-haskell"
constr = pkgName ++ " installed"
expected = [UserConstraint UserUnqualified (mkPackageName pkgName)
expected = [UserConstraint UserToplevel (mkPackageName pkgName)
PackagePropertyInstalled]
actual = [ x | (x, ys) <- readP_to_S parseUserConstraint constr
, all isSpace ys]
......@@ -55,7 +55,7 @@ readUserConstraintsTest =
pkgName = "template-haskell"
constr = pkgName ++ " installed"
expected = [[UserConstraint UserUnqualified (mkPackageName pkgName)
expected = [[UserConstraint UserToplevel (mkPackageName pkgName)
PackagePropertyInstalled]]
actual = [ x | (x, ys) <- readP_to_S parseUserConstraints constr
, all isSpace ys]
......
......@@ -582,10 +582,10 @@ exResolve db exts langs pkgConfigDb targets solver mbj indepGoals reorder
toQPN q pn = P.Q pp (C.mkPackageName pn)
where
pp = case q of
None -> P.PackagePath P.DefaultNamespace P.Unqualified
Indep x -> P.PackagePath (P.Independent x) P.Unqualified
Setup p -> P.PackagePath P.DefaultNamespace (P.Setup (C.mkPackageName p))
IndepSetup x p -> P.PackagePath (P.Independent x) (P.Setup (C.mkPackageName p))
None -> P.PackagePath P.DefaultNamespace P.QualToplevel
Indep x -> P.PackagePath (P.Independent x) P.QualToplevel
Setup p -> P.PackagePath P.DefaultNamespace (P.QualSetup (C.mkPackageName p))
IndepSetup x p -> P.PackagePath (P.Independent x) (P.QualSetup (C.mkPackageName p))
extractInstallPlan :: CI.SolverInstallPlan.SolverInstallPlan
-> [(ExamplePkgName, ExamplePkgVersion)]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment