Skip to content

Commit 43ec81e

Browse files
committed
avoid having specialized functions for style* . display
1 parent fde6c78 commit 43ec81e

2 files changed

Lines changed: 10 additions & 16 deletions

File tree

src/Stack/Build/ConstructPlan.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -949,17 +949,17 @@ pprintExceptions exceptions stackYaml parentMap wanted =
949949
Just (target:path) -> line <> "needed due to " <> encloseSep "" "" " -> " pathElems
950950
where
951951
pathElems =
952-
[displayTargetPkgId target] ++
952+
[styleTarget . display $ target] ++
953953
map display path ++
954954
[pkgIdent]
955955
where
956-
pkgIdent = displayCurrentPkgId (packageIdentifier pkg)
956+
pkgIdent = styleCurrent . display $ (packageIdentifier pkg)
957957
-- Skip these when they are redundant with 'NotInBuildPlan' info.
958958
pprintException (UnknownPackage name)
959959
| name `Set.member` allNotInBuildPlan = Nothing
960960
| name `HashSet.member` wiredInPackages =
961-
Just $ "Can't build a package with same name as a wired-in-package:" <+> displayCurrentPkgName name
962-
| otherwise = Just $ "Unknown package:" <+> displayCurrentPkgName name
961+
Just $ "Can't build a package with same name as a wired-in-package:" <+> (styleCurrent . display $ name)
962+
| otherwise = Just $ "Unknown package:" <+> (styleCurrent . display $ name)
963963

964964
pprintFlags flags
965965
| Map.null flags = ""
@@ -975,7 +975,7 @@ pprintExceptions exceptions stackYaml parentMap wanted =
975975
latestApplicable Nothing)
976976
-- TODO: For local packages, suggest editing constraints
977977
DependencyMismatch version -> Just $
978-
displayErrorPkgId (PackageIdentifier name version) <+>
978+
(styleError . display) (PackageIdentifier name version) <+>
979979
align ("must match" <+> goodRange <>
980980
latestApplicable (Just version))
981981
-- I think the main useful info is these explain why missing

src/Stack/PrettyPrint.hs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module Stack.PrettyPrint
1919
-- encourage consistency of color meanings.
2020
, styleWarning, styleError, styleGood
2121
, styleShell, styleFile, styleDir
22-
, displayTargetPkgId, displayCurrentPkgId, displayCurrentPkgName, displayErrorPkgId
22+
, styleCurrent, styleTarget
2323
, displayMilliseconds
2424
-- * Formatting utils
2525
, bulletedList
@@ -139,17 +139,11 @@ styleFile = bold . white
139139
styleDir :: AnsiDoc -> AnsiDoc
140140
styleDir = bold . blue
141141

142-
displayTargetPkgId :: PackageIdentifier -> AnsiDoc
143-
displayTargetPkgId = cyan . display
142+
styleCurrent :: AnsiDoc -> AnsiDoc
143+
styleCurrent = yellow
144144

145-
displayCurrentPkgId :: PackageIdentifier -> AnsiDoc
146-
displayCurrentPkgId = yellow . display
147-
148-
displayCurrentPkgName :: PackageName -> AnsiDoc
149-
displayCurrentPkgName = yellow . display
150-
151-
displayErrorPkgId :: PackageIdentifier -> AnsiDoc
152-
displayErrorPkgId = styleError . display
145+
styleTarget :: AnsiDoc -> AnsiDoc
146+
styleTarget = cyan
153147

154148
instance Display PackageName where
155149
display = fromString . packageNameString

0 commit comments

Comments
 (0)