Skip to content

Commit b61e031

Browse files
committed
Fewer imports from PrettyPrint qualified as Disp
1 parent 115fcd2 commit b61e031

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
@@ -201,15 +201,8 @@ import qualified Data.Set as Set
201201
import Network.URI (URI (..), nullURIAuth, parseURI)
202202
import System.Directory (createDirectoryIfMissing, makeAbsolute)
203203
import System.FilePath (isAbsolute, isPathSeparator, makeValid, splitFileName, (</>))
204-
import Text.PrettyPrint
205-
( Doc
206-
, render
207-
, semi
208-
, text
209-
, vcat
210-
, ($+$)
211-
)
212-
import qualified Text.PrettyPrint as Disp (empty, int, render, text)
204+
import Text.PrettyPrint (Doc, int, render, semi, text, vcat, ($+$))
205+
import qualified Text.PrettyPrint as Disp (empty)
213206

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

292285
parseProjectSkeleton
@@ -326,7 +319,7 @@ parseProjectSkeleton cacheDir httpTransport verbosity importsBy dupesMap project
326319
else do
327320
when
328321
(isUntrimmedUriConfigPath importLocPath)
329-
(noticeDoc verbosity $ untrimmedUriImportMsg (Disp.text "Warning:") importLocPath)
322+
(noticeDoc verbosity $ untrimmedUriImportMsg (text "Warning:") importLocPath)
330323
let fs = (\z -> CondNode z [normLocPath] mempty) <$> fieldsToConfig normSource (reverse acc)
331324
let uniqueFields = if uniqueImport `elem` seenImports then [] else xs
332325
atomicModifyIORef' dupesMap $ \dm -> (Map.insertWith (++) uniqueImport [Dupes uniqueImport normLocPath seenImportsBy] dm, ())
@@ -1324,13 +1317,13 @@ parseLegacyProjectConfig rootConfig bs =
13241317

13251318
showLegacyProjectConfig :: LegacyProjectConfig -> String
13261319
showLegacyProjectConfig config =
1327-
Disp.render $
1320+
render $
13281321
showConfig
13291322
(legacyProjectConfigFieldDescrs constraintSrc)
13301323
legacyPackageConfigSectionDescrs
13311324
legacyPackageConfigFGSectionDescrs
13321325
config
1333-
$+$ Disp.text ""
1326+
$+$ text ""
13341327
where
13351328
-- Note: ConstraintSource is unused when pretty-printing. We fake
13361329
-- it here to avoid having to pass it on call-sites. It's not great
@@ -1341,13 +1334,13 @@ legacyProjectConfigFieldDescrs :: ConstraintSource -> [FieldDescr LegacyProjectC
13411334
legacyProjectConfigFieldDescrs constraintSrc =
13421335
[ newLineListField
13431336
"packages"
1344-
(Disp.text . renderPackageLocationToken)
1337+
(text . renderPackageLocationToken)
13451338
parsePackageLocationTokenQ
13461339
legacyPackages
13471340
(\v flags -> flags{legacyPackages = v})
13481341
, newLineListField
13491342
"optional-packages"
1350-
(Disp.text . renderPackageLocationToken)
1343+
(text . renderPackageLocationToken)
13511344
parsePackageLocationTokenQ
13521345
legacyPackagesOptional
13531346
(\v flags -> flags{legacyPackagesOptional = v})
@@ -1458,7 +1451,7 @@ legacySharedConfigFieldDescrs constraintSrc =
14581451
. addFields
14591452
[ commaNewLineListFieldParsec
14601453
"package-dbs"
1461-
(Disp.text . showPackageDb)
1454+
(text . showPackageDb)
14621455
(fmap readPackageDb parsecToken)
14631456
configPackageDBs
14641457
(\v conf -> conf{configPackageDBs = v})
@@ -1751,8 +1744,8 @@ legacyPackageConfigFieldDescrs =
17511744
in FieldDescr
17521745
name
17531746
( \f -> case f of
1754-
Flag NoDumpBuildInfo -> Disp.text "False"
1755-
Flag DumpBuildInfo -> Disp.text "True"
1747+
Flag NoDumpBuildInfo -> text "False"
1748+
Flag DumpBuildInfo -> text "True"
17561749
_ -> Disp.empty
17571750
)
17581751
( \line str _ -> case () of
@@ -1779,9 +1772,9 @@ legacyPackageConfigFieldDescrs =
17791772
in FieldDescr
17801773
name
17811774
( \f -> case f of
1782-
Flag NoOptimisation -> Disp.text "False"
1783-
Flag NormalOptimisation -> Disp.text "True"
1784-
Flag MaximumOptimisation -> Disp.text "2"
1775+
Flag NoOptimisation -> text "False"
1776+
Flag NormalOptimisation -> text "True"
1777+
Flag MaximumOptimisation -> text "2"
17851778
_ -> Disp.empty
17861779
)
17871780
( \line str _ -> case () of
@@ -1804,10 +1797,10 @@ legacyPackageConfigFieldDescrs =
18041797
in FieldDescr
18051798
name
18061799
( \f -> case f of
1807-
Flag NoDebugInfo -> Disp.text "False"
1808-
Flag MinimalDebugInfo -> Disp.text "1"
1809-
Flag NormalDebugInfo -> Disp.text "True"
1810-
Flag MaximalDebugInfo -> Disp.text "3"
1800+
Flag NoDebugInfo -> text "False"
1801+
Flag MinimalDebugInfo -> text "1"
1802+
Flag NormalDebugInfo -> text "True"
1803+
Flag MaximalDebugInfo -> text "3"
18111804
_ -> Disp.empty
18121805
)
18131806
( \line str _ -> case () of
@@ -2132,6 +2125,6 @@ monoidFieldParsec name showF readF get' set =
21322125
-- otherwise are special syntax.
21332126
showTokenQ :: String -> Doc
21342127
showTokenQ "" = Disp.empty
2135-
showTokenQ x@('-' : '-' : _) = Disp.text (show x)
2136-
showTokenQ x@('.' : []) = Disp.text (show x)
2128+
showTokenQ x@('-' : '-' : _) = text (show x)
2129+
showTokenQ x@('.' : []) = text (show x)
21372130
showTokenQ x = showToken x

0 commit comments

Comments
 (0)