From 93ae2b5217d6119ef60e8dca6464a7d3097c06ab Mon Sep 17 00:00:00 2001 From: Phil de Joux Date: Mon, 25 Nov 2024 11:25:21 -0500 Subject: [PATCH] Add listSep --- .../PackageDescription/Check/Warning.hs | 65 +++++++++---------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/Cabal/src/Distribution/PackageDescription/Check/Warning.hs b/Cabal/src/Distribution/PackageDescription/Check/Warning.hs index a3105c28d64..067873bd0c4 100644 --- a/Cabal/src/Distribution/PackageDescription/Check/Warning.hs +++ b/Cabal/src/Distribution/PackageDescription/Check/Warning.hs @@ -1316,45 +1316,33 @@ ppExplanation BaseNoUpperBounds = ++ "version. For example if you have tested your package with 'base' " ++ "version 4.5 and 4.6 then use 'build-depends: base >= 4.5 && < 4.7'." ppExplanation (MissingUpperBounds ct names) = - let separator = "\n - " - in "On " - ++ ppCET ct - ++ ", " - ++ "these packages miss upper bounds:" - ++ separator - ++ List.intercalate separator names - ++ "\n" - ++ "Please add them. There is more information at https://pvp.haskell.org/" + "On " + ++ ppCET ct + ++ ", " + ++ "these packages miss upper bounds:" + ++ listSep names + ++ "Please add them. There is more information at https://pvp.haskell.org/" ppExplanation (LEQUpperBounds ct names) = - let separator = "\n - " - in "On " - ++ ppCET ct - ++ ", " - ++ "these packages have less than or equals (<=) upper bounds:" - ++ separator - ++ List.intercalate separator names - ++ "\n" - ++ "Please use less than (<) for upper bounds." + "On " + ++ ppCET ct + ++ ", " + ++ "these packages have less than or equals (<=) upper bounds:" + ++ listSep names + ++ "Please use less than (<) for upper bounds." ppExplanation (TrailingZeroUpperBounds ct names) = - let separator = "\n - " - in "On " - ++ ppCET ct - ++ ", " - ++ "these packages have upper bounds with trailing zeros:" - ++ separator - ++ List.intercalate separator names - ++ "\n" - ++ "Please avoid trailing zeros for upper bounds." + "On " + ++ ppCET ct + ++ ", " + ++ "these packages have upper bounds with trailing zeros:" + ++ listSep names + ++ "Please avoid trailing zeros for upper bounds." ppExplanation (GTLowerBounds ct names) = - let separator = "\n - " - in "On " - ++ ppCET ct - ++ ", " - ++ "these packages have greater than (>) lower bounds:" - ++ separator - ++ List.intercalate separator names - ++ "\n" - ++ "Please use greater than or equals (>=) for lower bounds." + "On " + ++ ppCET ct + ++ ", " + ++ "these packages have greater than (>) lower bounds:" + ++ listSep names + ++ "Please use greater than or equals (>=) for lower bounds." ppExplanation (SuspiciousFlagName invalidFlagNames) = "Suspicious flag names: " ++ unwords invalidFlagNames @@ -1516,6 +1504,11 @@ ppExplanation (WrongFieldForExpectedDocFiles extraDocFileSupport field paths) = -- * Formatting utilities +listSep :: [String] -> String +listSep names = + let separator = "\n - " + in separator ++ List.intercalate separator names ++ "\n" + commaSep :: [String] -> String commaSep = List.intercalate ", "