Skip to content

Commit 4c4b193

Browse files
committed
Fewer imports from PrettyPrint qualified as Disp
1 parent 02a16d5 commit 4c4b193

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, ())
@@ -1327,13 +1320,13 @@ parseLegacyProjectConfig rootConfig bs =
13271320

13281321
showLegacyProjectConfig :: LegacyProjectConfig -> String
13291322
showLegacyProjectConfig config =
1330-
Disp.render $
1323+
render $
13311324
showConfig
13321325
(legacyProjectConfigFieldDescrs constraintSrc)
13331326
legacyPackageConfigSectionDescrs
13341327
legacyPackageConfigFGSectionDescrs
13351328
config
1336-
$+$ Disp.text ""
1329+
$+$ text ""
13371330
where
13381331
-- Note: ConstraintSource is unused when pretty-printing. We fake
13391332
-- it here to avoid having to pass it on call-sites. It's not great
@@ -1344,13 +1337,13 @@ legacyProjectConfigFieldDescrs :: ConstraintSource -> [FieldDescr LegacyProjectC
13441337
legacyProjectConfigFieldDescrs constraintSrc =
13451338
[ newLineListField
13461339
"packages"
1347-
(Disp.text . renderPackageLocationToken)
1340+
(text . renderPackageLocationToken)
13481341
parsePackageLocationTokenQ
13491342
legacyPackages
13501343
(\v flags -> flags{legacyPackages = v})
13511344
, newLineListField
13521345
"optional-packages"
1353-
(Disp.text . renderPackageLocationToken)
1346+
(text . renderPackageLocationToken)
13541347
parsePackageLocationTokenQ
13551348
legacyPackagesOptional
13561349
(\v flags -> flags{legacyPackagesOptional = v})
@@ -1461,7 +1454,7 @@ legacySharedConfigFieldDescrs constraintSrc =
14611454
. addFields
14621455
[ commaNewLineListFieldParsec
14631456
"package-dbs"
1464-
(Disp.text . showPackageDb)
1457+
(text . showPackageDb)
14651458
(fmap readPackageDb parsecToken)
14661459
configPackageDBs
14671460
(\v conf -> conf{configPackageDBs = v})
@@ -1754,8 +1747,8 @@ legacyPackageConfigFieldDescrs =
17541747
in FieldDescr
17551748
name
17561749
( \f -> case f of
1757-
Flag NoDumpBuildInfo -> Disp.text "False"
1758-
Flag DumpBuildInfo -> Disp.text "True"
1750+
Flag NoDumpBuildInfo -> text "False"
1751+
Flag DumpBuildInfo -> text "True"
17591752
_ -> Disp.empty
17601753
)
17611754
( \line str _ -> case () of
@@ -1782,9 +1775,9 @@ legacyPackageConfigFieldDescrs =
17821775
in FieldDescr
17831776
name
17841777
( \f -> case f of
1785-
Flag NoOptimisation -> Disp.text "False"
1786-
Flag NormalOptimisation -> Disp.text "True"
1787-
Flag MaximumOptimisation -> Disp.text "2"
1778+
Flag NoOptimisation -> text "False"
1779+
Flag NormalOptimisation -> text "True"
1780+
Flag MaximumOptimisation -> text "2"
17881781
_ -> Disp.empty
17891782
)
17901783
( \line str _ -> case () of
@@ -1807,10 +1800,10 @@ legacyPackageConfigFieldDescrs =
18071800
in FieldDescr
18081801
name
18091802
( \f -> case f of
1810-
Flag NoDebugInfo -> Disp.text "False"
1811-
Flag MinimalDebugInfo -> Disp.text "1"
1812-
Flag NormalDebugInfo -> Disp.text "True"
1813-
Flag MaximalDebugInfo -> Disp.text "3"
1803+
Flag NoDebugInfo -> text "False"
1804+
Flag MinimalDebugInfo -> text "1"
1805+
Flag NormalDebugInfo -> text "True"
1806+
Flag MaximalDebugInfo -> text "3"
18141807
_ -> Disp.empty
18151808
)
18161809
( \line str _ -> case () of
@@ -2135,6 +2128,6 @@ monoidFieldParsec name showF readF get' set =
21352128
-- otherwise are special syntax.
21362129
showTokenQ :: String -> Doc
21372130
showTokenQ "" = Disp.empty
2138-
showTokenQ x@('-' : '-' : _) = Disp.text (show x)
2139-
showTokenQ x@('.' : []) = Disp.text (show x)
2131+
showTokenQ x@('-' : '-' : _) = text (show x)
2132+
showTokenQ x@('.' : []) = text (show x)
21402133
showTokenQ x = showToken x

0 commit comments

Comments
 (0)