File tree Expand file tree Collapse file tree 7 files changed +85
-1
lines changed
cabal-install/src/Distribution
cabal-testsuite/PackageTests/ProjectConfig/FlagsSemigroup Expand file tree Collapse file tree 7 files changed +85
-1
lines changed Original file line number Diff line number Diff line change @@ -1563,7 +1563,7 @@ legacyPackageConfigFieldDescrs =
15631563 parseTokenQ
15641564 configConfigureArgs
15651565 (\ v conf -> conf{configConfigureArgs = v})
1566- , simpleFieldParsec
1566+ , monoidFieldParsec
15671567 " flags"
15681568 dispFlagAssignment
15691569 parsecFlagAssignment
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ module Distribution.Deprecated.ParseUtils
4444 , showFreeText
4545 , field
4646 , simpleField
47+ , monoidField
4748 , listField
4849 , listFieldWithSep
4950 , spaceListField
@@ -52,6 +53,7 @@ module Distribution.Deprecated.ParseUtils
5253 , readPToMaybe
5354 , fieldParsec
5455 , simpleFieldParsec
56+ , monoidFieldParsec
5557 , listFieldParsec
5658 , commaListFieldParsec
5759 , commaNewLineListFieldParsec
@@ -254,6 +256,32 @@ simpleFieldParsec
254256simpleFieldParsec name showF readF get set =
255257 liftField get set $ fieldParsec name showF readF
256258
259+ monoidField
260+ :: Semigroup a
261+ => String
262+ -> (a -> Doc )
263+ -> ReadP a a
264+ -> (b -> a )
265+ -> (a -> b -> b )
266+ -> FieldDescr b
267+ monoidField name showF readF get set =
268+ liftField get set' $ field name showF readF
269+ where
270+ set' xs b = set (get b <> xs) b
271+
272+ monoidFieldParsec
273+ :: Semigroup a
274+ => String
275+ -> (a -> Doc )
276+ -> ParsecParser a
277+ -> (b -> a )
278+ -> (a -> b -> b )
279+ -> FieldDescr b
280+ monoidFieldParsec name showF readF get set =
281+ liftField get set' $ fieldParsec name showF readF
282+ where
283+ set' xs b = set (get b <> xs) b
284+
257285commaListFieldWithSepParsec
258286 :: Separator
259287 -> String
Original file line number Diff line number Diff line change 1+ # cabal build
2+ Configuration is affected by the following files:
3+ - cabal.project
4+ Resolving dependencies...
5+ Build profile: -w ghc-<GHCVER> -O1
6+ In order, the following will be built:
7+ - test-0.1 (lib) (first run)
8+ Configuring library for test-0.1...
9+ Preprocessing library for test-0.1...
10+ Building library for test-0.1...
Original file line number Diff line number Diff line change 1+ packages : .
2+
3+ package test
4+ -- test for #10767
5+ flags : -bar
6+ flags : -baz
7+ -- flags: -bar -baz -- this works
Original file line number Diff line number Diff line change 1+ import Test.Cabal.Prelude
2+
3+ main = cabalTest $ do
4+ cabal " build" []
Original file line number Diff line number Diff line change 1+ cabal-version : 3.0
2+ name : test
3+ version : 0.1
4+ license : BSD-3-Clause
5+ build-type : Simple
6+
7+ flag bar
8+ default : True
9+ manual : True
10+
11+ flag baz
12+ default : True
13+ manual : True
14+
15+ Library
16+ default-language : Haskell2010
17+ if flag(bar) || flag (baz)
18+ buildable : False
Original file line number Diff line number Diff line change 1+ ---
2+ synopsis : Merge 'flags' stanzas in cabal.project files
3+ packages : [cabal-install]
4+ prs : 10805
5+ issues : [10767]
6+ ---
7+
8+ Merge 'flags' stanzas in cabal.project files. Now
9+
10+ ```
11+ flags: -foo
12+ flags: -bar
13+ ```
14+
15+ is equivalent to ` flags: -foo -bar ` while before it was equivalent to ` flags: -bar `
16+ (only the latest stanza was taken into account, the other ones were silently
17+ ignored).
You can’t perform that action at this time.
0 commit comments