Commit 5e49e53c authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺
Browse files

Turn `allow-{newer,older}` into an accumulating field

This fixes the inconvenience occuring in `cabal.project` files of
separate `allow-*` statements overwriting each other. Currently,
without this patch,

    allow-newer: base
    allow-newer: directory

is *NOT* equivalent to

    allow-newer: base, directory

but rather to the last occurence of `allow-newer`, i.e.

    allow-newer: directory

This behaviour has been present since cabal 1.24
parent 0fdf2174
......@@ -829,12 +829,12 @@ legacySharedConfigFieldDescrs =
disp parse
configPreferences (\v conf -> conf { configPreferences = v })
, simpleField "allow-older"
, monoidField "allow-older"
(maybe mempty disp) (fmap Just parse)
(fmap unAllowOlder . configAllowOlder)
(\v conf -> conf { configAllowOlder = fmap AllowOlder v })
, simpleField "allow-newer"
, monoidField "allow-newer"
(maybe mempty disp) (fmap Just parse)
(fmap unAllowNewer . configAllowNewer)
(\v conf -> conf { configAllowNewer = fmap AllowNewer v })
......@@ -1253,6 +1253,13 @@ listFieldWithSep separator name showF readF get' set =
set' xs b = set (get' b ++ xs) b
showF' = separator . map showF
monoidField :: Monoid a => String -> (a -> Doc) -> ReadP a a
-> (b -> a) -> (a -> b -> b) -> FieldDescr b
monoidField name showF readF get' set =
liftField get' set' $ ParseUtils.field name showF readF
where
set' xs b = set (get' b `mappend` xs) b
--TODO: [code cleanup] local redefinition that should replace the version in
-- D.ParseUtils. This version avoid parse ambiguity for list element parsers
-- that have multiple valid parses of prefixes.
......
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