Skip to content

Commit 385413a

Browse files
committed
Fewer imports from PrettyPrint qualified as Disp
1 parent b8b8ff1 commit 385413a

File tree

1 file changed

+20
-27
lines changed
  • cabal-install/src/Distribution/Client/ProjectConfig

1 file changed

+20
-27
lines changed

cabal-install/src/Distribution/Client/ProjectConfig/Legacy.hs

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,8 @@ import qualified Data.Set as Set
204204
import Network.URI (URI (..), nullURIAuth, parseURI)
205205
import System.Directory (createDirectoryIfMissing, makeAbsolute)
206206
import System.FilePath (isAbsolute, isPathSeparator, makeValid, splitFileName, (</>))
207-
import Text.PrettyPrint
208-
( Doc
209-
, render
210-
, semi
211-
, text
212-
, vcat
213-
, ($+$)
214-
)
215-
import qualified Text.PrettyPrint as Disp (empty, int, render, text)
207+
import Text.PrettyPrint (Doc, int, render, semi, text, vcat, ($+$))
208+
import qualified Text.PrettyPrint as Disp (empty)
216209

217210
------------------------------------------------------------------
218211
-- Handle extended project config files with conditionals and imports.
@@ -289,7 +282,7 @@ type DupesMap = Map FilePath [Dupes]
289282
dupesMsg :: (FilePath, [Dupes]) -> Doc
290283
dupesMsg (duplicate, ds@(take 1 . sortOn dupesNormLocPath -> dupes)) =
291284
vcat $
292-
((text "Warning:" <+> Disp.int (length ds) <+> text "imports of" <+> text duplicate) <> semi)
285+
((text "Warning:" <+> int (length ds) <+> text "imports of" <+> text duplicate) <> semi)
293286
: ((\Dupes{..} -> duplicateImportMsg Disp.empty dupesUniqueImport dupesNormLocPath dupesSeenImportsBy) <$> dupes)
294287

295288
parseProjectSkeleton
@@ -329,7 +322,7 @@ parseProjectSkeleton cacheDir httpTransport verbosity importsBy dupesMap project
329322
else do
330323
when
331324
(isUntrimmedUriConfigPath importLocPath)
332-
(noticeDoc verbosity $ untrimmedUriImportMsg (Disp.text "Warning:") importLocPath)
325+
(noticeDoc verbosity $ untrimmedUriImportMsg (text "Warning:") importLocPath)
333326
let fs = (\z -> CondNode z [normLocPath] mempty) <$> fieldsToConfig normSource (reverse acc)
334327
let uniqueFields = if uniqueImport `elem` seenImports then [] else xs
335328
atomicModifyIORef' dupesMap $ \dm -> (Map.insertWith (++) uniqueImport [Dupes uniqueImport normLocPath seenImportsBy] dm, ())
@@ -1329,13 +1322,13 @@ parseLegacyProjectConfig rootConfig bs =
13291322

13301323
showLegacyProjectConfig :: LegacyProjectConfig -> String
13311324
showLegacyProjectConfig config =
1332-
Disp.render $
1325+
render $
13331326
showConfig
13341327
(legacyProjectConfigFieldDescrs constraintSrc)
13351328
legacyPackageConfigSectionDescrs
13361329
legacyPackageConfigFGSectionDescrs
13371330
config
1338-
$+$ Disp.text ""
1331+
$+$ text ""
13391332
where
13401333
-- Note: ConstraintSource is unused when pretty-printing. We fake
13411334
-- it here to avoid having to pass it on call-sites. It's not great
@@ -1346,13 +1339,13 @@ legacyProjectConfigFieldDescrs :: ConstraintSource -> [FieldDescr LegacyProjectC
13461339
legacyProjectConfigFieldDescrs constraintSrc =
13471340
[ newLineListField
13481341
"packages"
1349-
(Disp.text . renderPackageLocationToken)
1342+
(text . renderPackageLocationToken)
13501343
parsePackageLocationTokenQ
13511344
legacyPackages
13521345
(\v flags -> flags{legacyPackages = v})
13531346
, newLineListField
13541347
"optional-packages"
1355-
(Disp.text . renderPackageLocationToken)
1348+
(text . renderPackageLocationToken)
13561349
parsePackageLocationTokenQ
13571350
legacyPackagesOptional
13581351
(\v flags -> flags{legacyPackagesOptional = v})
@@ -1463,7 +1456,7 @@ legacySharedConfigFieldDescrs constraintSrc =
14631456
. addFields
14641457
[ commaNewLineListFieldParsec
14651458
"package-dbs"
1466-
(Disp.text . showPackageDb)
1459+
(text . showPackageDb)
14671460
(fmap readPackageDb parsecToken)
14681461
configPackageDBs
14691462
(\v conf -> conf{configPackageDBs = v})
@@ -1756,8 +1749,8 @@ legacyPackageConfigFieldDescrs =
17561749
in FieldDescr
17571750
name
17581751
( \f -> case f of
1759-
Flag NoDumpBuildInfo -> Disp.text "False"
1760-
Flag DumpBuildInfo -> Disp.text "True"
1752+
Flag NoDumpBuildInfo -> text "False"
1753+
Flag DumpBuildInfo -> text "True"
17611754
_ -> Disp.empty
17621755
)
17631756
( \line str _ -> case () of
@@ -1784,9 +1777,9 @@ legacyPackageConfigFieldDescrs =
17841777
in FieldDescr
17851778
name
17861779
( \f -> case f of
1787-
Flag NoOptimisation -> Disp.text "False"
1788-
Flag NormalOptimisation -> Disp.text "True"
1789-
Flag MaximumOptimisation -> Disp.text "2"
1780+
Flag NoOptimisation -> text "False"
1781+
Flag NormalOptimisation -> text "True"
1782+
Flag MaximumOptimisation -> text "2"
17901783
_ -> Disp.empty
17911784
)
17921785
( \line str _ -> case () of
@@ -1809,10 +1802,10 @@ legacyPackageConfigFieldDescrs =
18091802
in FieldDescr
18101803
name
18111804
( \f -> case f of
1812-
Flag NoDebugInfo -> Disp.text "False"
1813-
Flag MinimalDebugInfo -> Disp.text "1"
1814-
Flag NormalDebugInfo -> Disp.text "True"
1815-
Flag MaximalDebugInfo -> Disp.text "3"
1805+
Flag NoDebugInfo -> text "False"
1806+
Flag MinimalDebugInfo -> text "1"
1807+
Flag NormalDebugInfo -> text "True"
1808+
Flag MaximalDebugInfo -> text "3"
18161809
_ -> Disp.empty
18171810
)
18181811
( \line str _ -> case () of
@@ -2137,6 +2130,6 @@ monoidFieldParsec name showF readF get' set =
21372130
-- otherwise are special syntax.
21382131
showTokenQ :: String -> Doc
21392132
showTokenQ "" = Disp.empty
2140-
showTokenQ x@('-' : '-' : _) = Disp.text (show x)
2141-
showTokenQ x@('.' : []) = Disp.text (show x)
2133+
showTokenQ x@('-' : '-' : _) = text (show x)
2134+
showTokenQ x@('.' : []) = text (show x)
21422135
showTokenQ x = showToken x

0 commit comments

Comments
 (0)