Commit c67c365a authored by Tseen She's avatar Tseen She

caret / pvp operator accepts a set of versions. For example

  build-depends: network ^>= { 2.6.3.6, 2.7.0.2, 2.8.0.0, 3.0.1.0 }
parent e17b8e57
# 2.6.0.0 (current development version)
* TODO
* `^>=` takes multiple parameters
* 'check' reports warnings for various ghc-\*-options fields separately
([#5342](https://github.com/haskell/cabal/issues/5432)).
* `KnownExtension`: added new extension `DerivingVia`.
......
......@@ -420,8 +420,19 @@ instance Parsec VersionRange where
"==" -> do
P.spaces
(wild, v) <- verOrWild
pure $ (if wild then withinVersion else thisVersion) v
(do (wild, v) <- verOrWild
pure $ (if wild then withinVersion else thisVersion) v
<|>
(verSet' thisVersion =<< verSet))
"^>=" -> do
P.spaces
(do (wild, v) <- verOrWild
when wild $ P.unexpected $
"wild-card version after ^>= operator"
majorBoundVersion' v
<|>
(verSet' majorBoundVersion =<< verSet))
_ -> do
P.spaces
......@@ -431,7 +442,6 @@ instance Parsec VersionRange where
case op of
">=" -> pure $ orLaterVersion v
"<" -> pure $ earlierVersion v
"^>=" -> majorBoundVersion' v
"<=" -> pure $ orEarlierVersion v
">" -> pure $ laterVersion v
_ -> fail $ "Unknown version operator " ++ show op
......@@ -469,6 +479,31 @@ instance Parsec VersionRange where
(orLaterVersion u) (earlierVersion (majorUpperBound u))
embed vr = embedVersionRange vr
-- version set notation (e.g. "== { 0.0.1.0, 0.0.2.0, 0.1.0.0 }")
verSet' op vs = do
csv <- askCabalSpecVersion
if csv >= CabalSpecV3_0
then pure $ foldr1 unionVersionRanges (map op vs)
else fail $ unwords
[ "version set syntax used."
, "To use this syntax the package needs to specify at least 'cabal-version: 3.0'."
, "Alternatively, if broader compatibility is important then use"
, "a series of single version constraints joined with the || operator:"
, prettyShow (foldr1 unionVersionRanges (map op vs))
]
verSet :: CabalParsing m => m [Version]
verSet = do
_ <- P.char '{'
vs <- P.sepBy1 (P.spaces *> verPlain) (P.try (P.spaces *> P.char ','))
P.spaces
_ <- P.char '}'
pure vs
-- plain version without tags or wildcards
verPlain :: CabalParsing m => m Version
verPlain = mkVersion <$> P.sepBy1 P.integral (P.char '.')
-- either wildcard or normal version
verOrWild :: CabalParsing m => m (Bool, Version)
verOrWild = do
......
......@@ -2134,6 +2134,25 @@ system-dependent values for these fields.
renaming in ``build-depends``; however, this support has since been
removed and should not be used.
Starting with Cabal 3.0, a set notation for the ``==`` and ``^>=`` operator
is available. For instance,
::
tested-with: GHC == 8.6.3, GHC == 8.4.4, GHC == 8.2.2, GHC == 8.0.2,
GHC == 7.10.3, GHC == 7.8.4, GHC == 7.6.3, GHC == 7.4.2
build-depends: network ^>= 2.6.3.6 || ^>= 2.7.0.2 || ^>= 2.8.0.0 || ^>= 3.0.1.0
can be then written in a more convenient and concise form
::
tested-with: GHC == { 8.6.3, 8.4.4, 8.2.2, 8.0.2, 7.10.3, 7.8.4, 7.6.3, 7.4.2 }
build-depends: network ^>= { 2.6.3.6, 2.7.0.2, 2.8.0.0, 3.0.1.0 }
.. pkg-field:: other-modules: identifier list
A list of modules used by the component but not exposed to users.
......
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