-
Notifications
You must be signed in to change notification settings - Fork 710
caret operator accepts a set of versions #5906
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
Changes from all commits
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 |
---|---|---|
|
@@ -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,34 @@ 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 '{' | ||
P.spaces | ||
vs <- P.sepBy1 (verPlain <* P.spaces) (P.char ',' *> P.spaces) | ||
_ <- P.char '}' | ||
pure vs | ||
|
||
-- a plain version without tags or wildcards | ||
-- note: this uses P.integral which allows redundant zeros. | ||
-- This is not a problem because 'verPlain' is only used by | ||
-- 'verSet' which requires cabal > 3 | ||
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 | ||
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. @hvr if you look at this, this doesn't differentiate between I'll change that, hopefully nothing slipped on Hackage http://hackage.haskell.org/package/Cabal-2.4.1.0/docs/src/Distribution.Types.Version.html#line-99 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. See also #5138 where we took some measures to prevent denorm versions hitting hackage |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cabal-version: 2.5 | ||
name: version-sets | ||
version: 0 | ||
synopsis: version set notation | ||
|
||
library | ||
default-language: Haskell2010 | ||
build-depends: network == { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
VERSION: Just (mkVersion [2,5]) | ||
version-sets-1.cabal:8:31: | ||
unexpected "}" | ||
expecting space or integral | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cabal-version: 2.5 | ||
name: version-sets | ||
version: 0 | ||
synopsis: version set notation | ||
|
||
library | ||
default-language: Haskell2010 | ||
build-depends: network >= { 2.8.0.0 } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
VERSION: Just (mkVersion [2,5]) | ||
version-sets-2.cabal:8:29: | ||
unexpected "{" | ||
expecting space or integral | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cabal-version: 2.5 | ||
name: version-sets | ||
version: 0 | ||
synopsis: version set notation | ||
|
||
library | ||
default-language: Haskell2010 | ||
build-depends: network == { 2.8.0.0, } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
VERSION: Just (mkVersion [2,5]) | ||
version-sets-3.cabal:8:40: | ||
unexpected "}" | ||
expecting space or integral | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cabal-version: 2.5 | ||
name: version-sets | ||
version: 0 | ||
synopsis: version set notation | ||
|
||
library | ||
default-language: Haskell2010 | ||
build-depends: network == { 2.8.* } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
VERSION: Just (mkVersion [2,5]) | ||
version-sets-4.cabal:8:35: | ||
unexpected "*" | ||
expecting integral | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
cabal-version: 2.5 | ||
name: version-sets | ||
version: 0 | ||
synopsis: version set notation | ||
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 } | ||
|
||
library | ||
default-language: Haskell2010 | ||
build-depends: network ^>= {0} | ||
build-depends: base == {1}, base == { 1 }, base == {1,2}, base == {1.2}, base == {1.2,3.4} | ||
build-depends: 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: Cabal ^>= { 2.4.1.1, 2.2.0.0 } |
Uh oh!
There was an error while loading. Please reload this page.