Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pantry: remove displayc #4253

Merged
merged 1 commit into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Options/Applicative/Complicated.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ complicatedOptions
-> ExceptT b (Writer (Mod CommandFields (b,a))) ()
-- ^ commands (use 'addCommand')
-> IO (a,b)
complicatedOptions numericVersion versionString numericHpackVersion h pd footerStr commonParser mOnFailure commandParser =
complicatedOptions numericVersion stringVersion numericHpackVersion h pd footerStr commonParser mOnFailure commandParser =
do args <- getArgs
(a,(b,c)) <- case execParserPure (prefs noBacktrack) parser args of
Failure _ | null args -> withArgs ["--help"] (execParser parser)
Expand All @@ -55,8 +55,8 @@ complicatedOptions numericVersion versionString numericHpackVersion h pd footerS
where parser = info (helpOption <*> versionOptions <*> complicatedParser "COMMAND|FILE" commonParser commandParser) desc
desc = fullDesc <> header h <> progDesc pd <> footer footerStr
versionOptions =
case versionString of
Nothing -> versionOption (displayC numericVersion)
case stringVersion of
Nothing -> versionOption (versionString numericVersion)
Just s -> versionOption s <*> numericVersionOption <*> numericHpackVersionOption
versionOption s =
infoOption
Expand All @@ -65,7 +65,7 @@ complicatedOptions numericVersion versionString numericHpackVersion h pd footerS
help "Show version")
numericVersionOption =
infoOption
(displayC numericVersion)
(versionString numericVersion)
(long "numeric-version" <>
help "Show only version number")
numericHpackVersionOption =
Expand Down
6 changes: 3 additions & 3 deletions src/Stack/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ checkCabalVersion = do
when (allowNewer && cabalVer < $(mkVersion "1.22")) $ throwM $
CabalVersionException $
"Error: --allow-newer requires at least Cabal version 1.22, but version " ++
displayC cabalVer ++
versionString cabalVer ++
" was found."

newtype CabalVersionException = CabalVersionException { unCabalVersionException :: String }
Expand All @@ -176,7 +176,7 @@ warnIfExecutablesWithSameNameCouldBeOverwritten locals plan = do
exesText pkgs =
T.intercalate
", "
["'" <> displayC p <> ":" <> exe <> "'" | p <- pkgs]
["'" <> T.pack (packageNameString p) <> ":" <> exe <> "'" | p <- pkgs]
(logWarn . display . T.unlines . concat)
[ [ "Building " <> exe_s <> " " <> exesText toBuild <> "." ]
, [ "Only one of them will be available via 'stack exec' or locally installed."
Expand Down Expand Up @@ -389,7 +389,7 @@ rawBuildInfo = do
]
where
localToPair lp =
(displayC $ packageName p, value)
(T.pack $ packageNameString $ packageName p, value)
where
p = lpPackage lp
value = object
Expand Down
8 changes: 4 additions & 4 deletions src/Stack/Build/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ markExeInstalled :: (MonadReader env m, HasEnvConfig env, MonadIO m, MonadThrow
markExeInstalled loc ident = do
dir <- exeInstalledDir loc
ensureDir dir
ident' <- parseRelFile $ displayC ident
ident' <- parseRelFile $ packageIdentifierString ident
let fp = toFilePath $ dir </> ident'
-- Remove old install records for this package.
-- TODO: This is a bit in-efficient. Put all this metadata into one file?
Expand All @@ -103,7 +103,7 @@ markExeNotInstalled :: (MonadReader env m, HasEnvConfig env, MonadIO m, MonadThr
=> InstallLocation -> PackageIdentifier -> m ()
markExeNotInstalled loc ident = do
dir <- exeInstalledDir loc
ident' <- parseRelFile $ displayC ident
ident' <- parseRelFile $ packageIdentifierString ident
liftIO $ ignoringAbsence (removeFile $ dir </> ident')

buildCacheFile :: (HasEnvConfig env, MonadReader env m, MonadThrow m)
Expand Down Expand Up @@ -185,7 +185,7 @@ flagCacheFile installed = do
rel <- parseRelFile $
case installed of
Library _ gid _ -> ghcPkgIdString gid
Executable ident -> displayC ident
Executable ident -> packageIdentifierString ident
dir <- flagCacheLocal
return $ dir </> rel

Expand Down Expand Up @@ -257,7 +257,7 @@ precompiledCacheFile loc copts installedPackageIDs = do
ec <- view envConfigL

compiler <- view actualCompilerVersionL >>= parseRelDir . compilerVersionString
cabal <- view cabalVersionL >>= parseRelDir . displayC
cabal <- view cabalVersionL >>= parseRelDir . versionString

-- The goal here is to come up with a string representing the
-- package location which is unique. Luckily @TreeKey@s are exactly
Expand Down
40 changes: 20 additions & 20 deletions src/Stack/Build/ConstructPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ mkUnregisterLocal tasks dirtyReason localDumpPkgs sourceMap initialBuildSteps =
= Just "Switching to snapshot installed package"
-- Check if a dependency is going to be unregistered
| (dep, _):_ <- mapMaybe (`Map.lookup` toUnregister) deps
= Just $ "Dependency being unregistered: " <> displayC dep
= Just $ "Dependency being unregistered: " <> T.pack (packageIdentifierString dep)
-- None of the above, keep it!
| otherwise = Nothing
where
Expand Down Expand Up @@ -539,7 +539,7 @@ installPackageGivenDeps isAllInOne ps package minstalled (missing, present, minL
shouldInstall <- checkDirtiness ps installed package present (wanted ctx)
return $ if shouldInstall then Nothing else Just installed
(Just _, False) -> do
let t = T.intercalate ", " $ map (displayC . pkgName) (Set.toList missing)
let t = T.intercalate ", " $ map (T.pack . packageNameString . pkgName) (Set.toList missing)
tell mempty { wDirty = Map.singleton name $ "missing dependencies: " <> addEllipsis t }
return Nothing
(Nothing, _) -> return Nothing
Expand Down Expand Up @@ -643,9 +643,9 @@ addPackageDeps treatAsDep package = do
[ "WARNING: Ignoring out of range dependency"
, reason
, ": "
, displayC $ PackageIdentifier depname (adrVersion adr)
, T.pack $ packageIdentifierString $ PackageIdentifier depname (adrVersion adr)
, ". "
, displayC $ packageName package
, T.pack $ packageNameString $ packageName package
, " requires: "
, versionRangeText range
]
Expand Down Expand Up @@ -865,7 +865,7 @@ toolWarningText (ToolWarning (ExeName toolName) pkgName) =
"No packages found in snapshot which provide a " <>
T.pack (show toolName) <>
" executable, which is a build-tool dependency of " <>
displayC pkgName
T.pack (packageNameString pkgName)

-- | Strip out anything from the @Plan@ intended for the local database
stripLocals :: Plan -> Plan
Expand Down Expand Up @@ -1005,7 +1005,7 @@ pprintExceptions exceptions stackYaml stackRoot parentMap wanted =

pprintException (DependencyCycleDetected pNames) = Just $
flow "Dependency cycle detected in packages:" <> line <>
indent 4 (encloseSep "[" "]" "," (map (style Error . displayC) pNames))
indent 4 (encloseSep "[" "]" "," (map (style Error . fromString . packageNameString) pNames))
pprintException (DependencyPlanFailures pkg pDeps) =
case mapMaybe pprintDep (Map.toList pDeps) of
[] -> Nothing
Expand All @@ -1019,18 +1019,18 @@ pprintExceptions exceptions stackYaml stackRoot parentMap wanted =
Just (target:path) -> line <> flow "needed due to" <+> encloseSep "" "" " -> " pathElems
where
pathElems =
[style Target . displayC $ target] ++
map displayC path ++
[style Target . fromString . packageIdentifierString $ target] ++
map (fromString . packageIdentifierString) path ++
[pkgIdent]
where
pkgName = style Current . displayC $ packageName pkg
pkgIdent = style Current . displayC $ packageIdentifier pkg
pkgName = style Current . fromString . packageNameString $ packageName pkg
pkgIdent = style Current . fromString . packageIdentifierString $ packageIdentifier pkg
-- Skip these when they are redundant with 'NotInBuildPlan' info.
pprintException (UnknownPackage name)
| name `Set.member` allNotInBuildPlan = Nothing
| name `Set.member` wiredInPackages =
Just $ flow "Can't build a package with same name as a wired-in-package:" <+> (style Current . displayC $ name)
| otherwise = Just $ flow "Unknown package:" <+> (style Current . displayC $ name)
Just $ flow "Can't build a package with same name as a wired-in-package:" <+> (style Current . fromString . packageNameString $ name)
| otherwise = Just $ flow "Unknown package:" <+> (style Current . fromString . packageNameString $ name)

pprintFlags flags
| Map.null flags = ""
Expand All @@ -1040,27 +1040,27 @@ pprintExceptions exceptions stackYaml stackRoot parentMap wanted =

pprintDep (name, (range, mlatestApplicable, badDep)) = case badDep of
NotInBuildPlan -> Just $
style Error (displayC name) <+>
style Error (fromString $ packageNameString name) <+>
align ((if range == Cabal.anyVersion
then flow "needed"
else flow "must match" <+> goodRange) <> "," <> softline <>
flow "but the stack configuration has no specified version" <+>
latestApplicable Nothing)
-- TODO: For local packages, suggest editing constraints
DependencyMismatch version -> Just $
(style Error . displayC) (PackageIdentifier name version) <+>
(style Error . fromString . packageIdentifierString) (PackageIdentifier name version) <+>
align (flow "from stack configuration does not match" <+> goodRange <+>
latestApplicable (Just version))
-- I think the main useful info is these explain why missing
-- packages are needed. Instead lets give the user the shortest
-- path from a target to the package.
Couldn'tResolveItsDependencies _version -> Nothing
HasNoLibrary -> Just $
style Error (displayC name) <+>
style Error (fromString $ packageNameString name) <+>
align (flow "is a library dependency, but the package provides no library")
BDDependencyCycleDetected names -> Just $
style Error (displayC name) <+>
align (flow $ "dependency cycle detected: " ++ intercalate ", " (map displayC names))
style Error (fromString $ packageNameString name) <+>
align (flow $ "dependency cycle detected: " ++ intercalate ", " (map packageNameString names))
where
goodRange = style Good (fromString (Cabal.display range))
latestApplicable mversion =
Expand All @@ -1073,7 +1073,7 @@ pprintExceptions exceptions stackYaml stackRoot parentMap wanted =
| Just laVer == mversion -> softline <>
flow "(latest matching version is specified)"
| otherwise -> softline <>
flow "(latest matching version is" <+> style Good (displayC laVer) <> ")"
flow "(latest matching version is" <+> style Good (fromString $ versionString laVer) <> ")"

-- | Get the shortest reason for the package to be in the build plan. In
-- other words, trace the parent dependencies back to a 'wanted'
Expand Down Expand Up @@ -1126,14 +1126,14 @@ data DepsPath = DepsPath
startDepsPath :: PackageIdentifier -> DepsPath
startDepsPath ident = DepsPath
{ dpLength = 1
, dpNameLength = T.length (displayC (pkgName ident))
, dpNameLength = length (packageNameString (pkgName ident))
, dpPath = [ident]
}

extendDepsPath :: PackageIdentifier -> DepsPath -> DepsPath
extendDepsPath ident dp = DepsPath
{ dpLength = dpLength dp + 1
, dpNameLength = dpNameLength dp + T.length (displayC (pkgName ident))
, dpNameLength = dpNameLength dp + length (packageNameString (pkgName ident))
, dpPath = [ident]
}

Expand Down
Loading