Skip to content
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

caret operator accepts a set of versions #5906

Merged
merged 2 commits into from
Mar 2, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cabal/Cabal.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ extra-source-files:
tests/ParserTests/errors/spdx-2.errors
tests/ParserTests/errors/spdx-3.cabal
tests/ParserTests/errors/spdx-3.errors
tests/ParserTests/errors/version-sets-1.cabal
tests/ParserTests/errors/version-sets-1.errors
tests/ParserTests/errors/version-sets-2.cabal
tests/ParserTests/errors/version-sets-2.errors
tests/ParserTests/errors/version-sets-3.cabal
tests/ParserTests/errors/version-sets-3.errors
tests/ParserTests/errors/version-sets-4.cabal
tests/ParserTests/errors/version-sets-4.errors
tests/ParserTests/ipi/Includes2.cabal
tests/ParserTests/ipi/Includes2.expr
tests/ParserTests/ipi/Includes2.format
Expand Down Expand Up @@ -172,6 +180,9 @@ extra-source-files:
tests/ParserTests/regressions/th-lift-instances.cabal
tests/ParserTests/regressions/th-lift-instances.expr
tests/ParserTests/regressions/th-lift-instances.format
tests/ParserTests/regressions/version-sets.cabal
tests/ParserTests/regressions/version-sets.expr
tests/ParserTests/regressions/version-sets.format
tests/ParserTests/regressions/wl-pprint-indef.cabal
tests/ParserTests/regressions/wl-pprint-indef.expr
tests/ParserTests/regressions/wl-pprint-indef.format
Expand Down
2 changes: 1 addition & 1 deletion Cabal/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 2.6.0.0 (current development version)
* TODO
* `^>=` takes multiple parameters
* Introduce set notation for `^>=` and `==` operators.
* 'check' reports warnings for various ghc-\*-options fields separately
([#5342](https://github.com/haskell/cabal/issues/5432)).
* `KnownExtension`: added new extension `DerivingVia`.
Expand Down
7 changes: 5 additions & 2 deletions Cabal/Distribution/Types/VersionRange.hs
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,15 @@ instance Parsec VersionRange where
verSet :: CabalParsing m => m [Version]
verSet = do
_ <- P.char '{'
vs <- P.sepBy1 (P.spaces *> verPlain) (P.try (P.spaces *> P.char ','))
P.spaces
vs <- P.sepBy1 (verPlain <* P.spaces) (P.char ',' *> P.spaces)
_ <- P.char '}'
pure vs

-- plain version without tags or wildcards
-- 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 '.')
hvr marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
5 changes: 5 additions & 0 deletions Cabal/tests/ParserTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ errorTests = testGroup "errors"
, errorTest "spdx-2.cabal"
, errorTest "spdx-3.cabal"
, errorTest "removed-fields.cabal"
, errorTest "version-sets-1.cabal"
, errorTest "version-sets-2.cabal"
, errorTest "version-sets-3.cabal"
, errorTest "version-sets-4.cabal"
]

errorTest :: FilePath -> TestTree
Expand Down Expand Up @@ -159,6 +163,7 @@ regressionTests = testGroup "regressions"
, regressionTest "spdx-3.cabal"
, regressionTest "hidden-main-lib.cabal"
, regressionTest "jaeger-flamegraph.cabal"
, regressionTest "version-sets.cabal"
]

regressionTest :: FilePath -> TestTree
Expand Down
8 changes: 8 additions & 0 deletions Cabal/tests/ParserTests/errors/version-sets-1.cabal
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 == { }
5 changes: 5 additions & 0 deletions Cabal/tests/ParserTests/errors/version-sets-1.errors
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

8 changes: 8 additions & 0 deletions Cabal/tests/ParserTests/errors/version-sets-2.cabal
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 }
5 changes: 5 additions & 0 deletions Cabal/tests/ParserTests/errors/version-sets-2.errors
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

8 changes: 8 additions & 0 deletions Cabal/tests/ParserTests/errors/version-sets-3.cabal
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, }
5 changes: 5 additions & 0 deletions Cabal/tests/ParserTests/errors/version-sets-3.errors
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

8 changes: 8 additions & 0 deletions Cabal/tests/ParserTests/errors/version-sets-4.cabal
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.* }
5 changes: 5 additions & 0 deletions Cabal/tests/ParserTests/errors/version-sets-4.errors
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

18 changes: 18 additions & 0 deletions Cabal/tests/ParserTests/regressions/version-sets.cabal
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 }
Loading