@@ -47,14 +47,16 @@ quote ('"':cs) = '\\' : '"' : quote cs
4747quote (c:cs) = c : quote cs
4848quote [] = []
4949
50−-- | When a flag is specified multiple times, the first occurrence counts. This
51−-- is counter-intuitive, IMHO, but it's how cabal does it. Flag names are
52−-- spelled in all lowercase.
50+-- | When a flag is specified multiple times, the last occurrence counts. Flag
51+-- names are spelled all lowercase.
5352--
5453-- >>> normalizeCabalFlags [(mkFlagName "foo", True), (mkFlagName "FOO", True), (mkFlagName "Foo", False)]
55−-- [(FlagName "foo",True)]
54+-- [(FlagName "foo",False)]
5655
5756normalizeCabalFlags :: FlagAssignment -> FlagAssignment
58−normalizeCabalFlags flags' = nubBy ((==) `on` fst) (sortBy (compare `on` fst) flags)
59− where
60− flags = [ (mkFlagName (lowercase (unFlagName n)), b) | (n, b) <- flags' ]
57+normalizeCabalFlags flags =
58+ sortBy (compare `on` fst) $
59+ reverse $
60+ nubBy ((==) `on` fst) $
61+ reverse $
62+ [ (mkFlagName (lowercase (unFlagName n)), b) | (n, b) <- flags ]