From 215e688e7e40fd8bd7fc259d3b4b06f58f5a99ca Mon Sep 17 00:00:00 2001 From: Heather Date: Tue, 1 Dec 2015 14:45:45 +0400 Subject: [PATCH] cabal-install: minor random improvements --- cabal-install/Distribution/Client/Dependency.hs | 8 ++++---- cabal-install/Distribution/Client/Haddock.hs | 5 ++--- cabal-install/Distribution/Client/Manpage.hs | 10 +++++----- cabal-install/Distribution/Client/SrcDist.hs | 7 +++---- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/cabal-install/Distribution/Client/Dependency.hs b/cabal-install/Distribution/Client/Dependency.hs index 5e122254ebd..8f20e7a4f9c 100644 --- a/cabal-install/Distribution/Client/Dependency.hs +++ b/cabal-install/Distribution/Client/Dependency.hs @@ -282,7 +282,7 @@ dontUpgradeNonUpgradeablePackages params = [ LabeledPackageConstraint (PackageConstraintInstalled pkgname) ConstraintSourceNonUpgradeablePackage - | all (/=PackageName "base") (depResolverTargets params) + | notElem (PackageName "base") (depResolverTargets params) , pkgname <- map PackageName [ "base", "ghc-prim", "integer-gmp" , "integer-simple" ] , isInstalled pkgname ] @@ -601,8 +601,8 @@ interpretPackagesPreference selected defaultPref prefs = [ (pkgname, pref) | PackageInstalledPreference pkgname pref <- prefs ] installPrefDefault = case defaultPref of - PreferAllLatest -> \_ -> PreferLatest - PreferAllInstalled -> \_ -> PreferInstalled + PreferAllLatest -> const PreferLatest + PreferAllInstalled -> const PreferInstalled PreferLatestForSelected -> \pkgname -> -- When you say cabal install foo, what you really mean is, prefer the -- latest version of foo, but the installed version of everything else @@ -637,7 +637,7 @@ validateSolverResult platform comp indepGoals pkgs = formatPkgProblems = formatProblemMessage . map showPlanPackageProblem formatPlanProblems = formatProblemMessage . map InstallPlan.showPlanProblem - formatProblemMessage problems = + formatProblemMessage problems = unlines $ "internal error: could not construct a valid install plan." : "The proposed (invalid) plan contained the following problems:" diff --git a/cabal-install/Distribution/Client/Haddock.hs b/cabal-install/Distribution/Client/Haddock.hs index 487be04a06a..3cb5b0334e0 100644 --- a/cabal-install/Distribution/Client/Haddock.hs +++ b/cabal-install/Distribution/Client/Haddock.hs @@ -17,6 +17,7 @@ module Distribution.Client.Haddock where import Data.List (maximumBy) +import Data.Foldable (forM_) import System.Directory (createDirectoryIfMissing, renameFile) import System.FilePath ((), splitFileName) import Distribution.Package @@ -40,9 +41,7 @@ regenerateHaddockIndex :: Verbosity regenerateHaddockIndex verbosity pkgs conf index = do (paths, warns) <- haddockPackagePaths pkgs' Nothing let paths' = [ (interface, html) | (interface, Just html) <- paths] - case warns of - Nothing -> return () - Just m -> debug verbosity m + forM_ warns (debug verbosity) (confHaddock, _, _) <- requireProgramVersion verbosity haddockProgram diff --git a/cabal-install/Distribution/Client/Manpage.hs b/cabal-install/Distribution/Client/Manpage.hs index 8e48ead29d8..58c01bc07b2 100644 --- a/cabal-install/Distribution/Client/Manpage.hs +++ b/cabal-install/Distribution/Client/Manpage.hs @@ -49,7 +49,7 @@ manpage pname commands = unlines $ ] ++ concatMap (commandSynopsisLines pname) commands ++ [ ".SH DESCRIPTION" - , "Cabal is the standard package system for Haskell software. It helps people to configure, " + , "Cabal is the standard package system for Haskell software. It helps people to configure, " , "build and install Haskell software and to distribute it easily to other users and developers." , "" , "The command line " ++ pname ++ " tool (also referred to as cabal-install) helps with " @@ -84,7 +84,7 @@ commandSynopsisLines _ (CommandSpec _ _ HiddenCommand) = [] commandDetailsLines :: String -> CommandSpec action -> [String] commandDetailsLines pname (CommandSpec ui _ NormalCommand) = - [ ".B " ++ pname ++ " " ++ (commandName ui) + [ ".B " ++ pname ++ " " ++ (commandName ui) , "" , commandUsage ui pname , "" @@ -96,7 +96,7 @@ commandDetailsLines pname (CommandSpec ui _ NormalCommand) = ] ++ optionsLines ui ++ [ ".RE" - , "" + , "" ] where optional field = @@ -109,10 +109,10 @@ optionsLines :: CommandUI flags -> [String] optionsLines command = concatMap optionLines (concatMap optionDescr (commandOptions command ParseArgs)) data ArgumentRequired = Optional | Required -type OptionArg = (ArgumentRequired, ArgPlaceHolder) +type OptionArg = (ArgumentRequired, ArgPlaceHolder) optionLines :: OptDescr flags -> [String] -optionLines (ReqArg description (optionChars, optionStrings) placeHolder _ _) = +optionLines (ReqArg description (optionChars, optionStrings) placeHolder _ _) = argOptionLines description optionChars optionStrings (Required, placeHolder) optionLines (OptArg description (optionChars, optionStrings) placeHolder _ _ _) = argOptionLines description optionChars optionStrings (Optional, placeHolder) diff --git a/cabal-install/Distribution/Client/SrcDist.hs b/cabal-install/Distribution/Client/SrcDist.hs index 437ef838bcd..4499cc572f9 100644 --- a/cabal-install/Distribution/Client/SrcDist.hs +++ b/cabal-install/Distribution/Client/SrcDist.hs @@ -33,7 +33,7 @@ import Distribution.Verbosity (Verbosity) import Distribution.Version (Version(..), orLaterVersion) import System.FilePath ((), (<.>)) -import Control.Monad (when, unless) +import Control.Monad (when, unless, liftM) import System.Directory (doesFileExist, removeFile, canonicalizePath) import System.Process (runProcess, waitForProcess) import System.Exit (ExitCode(..)) @@ -41,9 +41,8 @@ import System.Exit (ExitCode(..)) -- |Create a source distribution. sdist :: SDistFlags -> SDistExFlags -> IO () sdist flags exflags = do - pkg <- return . flattenPackageDescription - =<< readPackageDescription verbosity - =<< defaultPackageDesc verbosity + pkg <- liftM flattenPackageDescription + (readPackageDescription verbosity =<< defaultPackageDesc verbosity) let withDir = if not needMakeArchive then (\f -> f tmpTargetDir) else withTempDirectory verbosity tmpTargetDir "sdist." -- 'withTempDir' fails if we don't create 'tmpTargetDir'...