Skip to content

Commit 74e9383

Browse files
committed
Merge pull request #2941 from Heather/dep
cabal-install: minor random improvements
2 parents 96a8f7b + 215e688 commit 74e9383

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

cabal-install/Distribution/Client/Dependency.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ dontUpgradeNonUpgradeablePackages params =
282282
[ LabeledPackageConstraint
283283
(PackageConstraintInstalled pkgname)
284284
ConstraintSourceNonUpgradeablePackage
285-
| all (/=PackageName "base") (depResolverTargets params)
285+
| notElem (PackageName "base") (depResolverTargets params)
286286
, pkgname <- map PackageName [ "base", "ghc-prim", "integer-gmp"
287287
, "integer-simple" ]
288288
, isInstalled pkgname ]
@@ -601,8 +601,8 @@ interpretPackagesPreference selected defaultPref prefs =
601601
[ (pkgname, pref)
602602
| PackageInstalledPreference pkgname pref <- prefs ]
603603
installPrefDefault = case defaultPref of
604-
PreferAllLatest -> \_ -> PreferLatest
605-
PreferAllInstalled -> \_ -> PreferInstalled
604+
PreferAllLatest -> const PreferLatest
605+
PreferAllInstalled -> const PreferInstalled
606606
PreferLatestForSelected -> \pkgname ->
607607
-- When you say cabal install foo, what you really mean is, prefer the
608608
-- latest version of foo, but the installed version of everything else
@@ -637,7 +637,7 @@ validateSolverResult platform comp indepGoals pkgs =
637637
formatPkgProblems = formatProblemMessage . map showPlanPackageProblem
638638
formatPlanProblems = formatProblemMessage . map InstallPlan.showPlanProblem
639639

640-
formatProblemMessage problems =
640+
formatProblemMessage problems =
641641
unlines $
642642
"internal error: could not construct a valid install plan."
643643
: "The proposed (invalid) plan contained the following problems:"

cabal-install/Distribution/Client/Haddock.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module Distribution.Client.Haddock
1717
where
1818

1919
import Data.List (maximumBy)
20+
import Data.Foldable (forM_)
2021
import System.Directory (createDirectoryIfMissing, renameFile)
2122
import System.FilePath ((</>), splitFileName)
2223
import Distribution.Package
@@ -40,9 +41,7 @@ regenerateHaddockIndex :: Verbosity
4041
regenerateHaddockIndex verbosity pkgs conf index = do
4142
(paths, warns) <- haddockPackagePaths pkgs' Nothing
4243
let paths' = [ (interface, html) | (interface, Just html) <- paths]
43-
case warns of
44-
Nothing -> return ()
45-
Just m -> debug verbosity m
44+
forM_ warns (debug verbosity)
4645

4746
(confHaddock, _, _) <-
4847
requireProgramVersion verbosity haddockProgram

cabal-install/Distribution/Client/Manpage.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ manpage pname commands = unlines $
4949
] ++
5050
concatMap (commandSynopsisLines pname) commands ++
5151
[ ".SH DESCRIPTION"
52-
, "Cabal is the standard package system for Haskell software. It helps people to configure, "
52+
, "Cabal is the standard package system for Haskell software. It helps people to configure, "
5353
, "build and install Haskell software and to distribute it easily to other users and developers."
5454
, ""
5555
, "The command line " ++ pname ++ " tool (also referred to as cabal-install) helps with "
@@ -84,7 +84,7 @@ commandSynopsisLines _ (CommandSpec _ _ HiddenCommand) = []
8484

8585
commandDetailsLines :: String -> CommandSpec action -> [String]
8686
commandDetailsLines pname (CommandSpec ui _ NormalCommand) =
87-
[ ".B " ++ pname ++ " " ++ (commandName ui)
87+
[ ".B " ++ pname ++ " " ++ (commandName ui)
8888
, ""
8989
, commandUsage ui pname
9090
, ""
@@ -96,7 +96,7 @@ commandDetailsLines pname (CommandSpec ui _ NormalCommand) =
9696
] ++
9797
optionsLines ui ++
9898
[ ".RE"
99-
, ""
99+
, ""
100100
]
101101
where
102102
optional field =
@@ -109,10 +109,10 @@ optionsLines :: CommandUI flags -> [String]
109109
optionsLines command = concatMap optionLines (concatMap optionDescr (commandOptions command ParseArgs))
110110

111111
data ArgumentRequired = Optional | Required
112-
type OptionArg = (ArgumentRequired, ArgPlaceHolder)
112+
type OptionArg = (ArgumentRequired, ArgPlaceHolder)
113113

114114
optionLines :: OptDescr flags -> [String]
115-
optionLines (ReqArg description (optionChars, optionStrings) placeHolder _ _) =
115+
optionLines (ReqArg description (optionChars, optionStrings) placeHolder _ _) =
116116
argOptionLines description optionChars optionStrings (Required, placeHolder)
117117
optionLines (OptArg description (optionChars, optionStrings) placeHolder _ _ _) =
118118
argOptionLines description optionChars optionStrings (Optional, placeHolder)

cabal-install/Distribution/Client/SrcDist.hs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,16 @@ import Distribution.Verbosity (Verbosity)
3333
import Distribution.Version (Version(..), orLaterVersion)
3434

3535
import System.FilePath ((</>), (<.>))
36-
import Control.Monad (when, unless)
36+
import Control.Monad (when, unless, liftM)
3737
import System.Directory (doesFileExist, removeFile, canonicalizePath)
3838
import System.Process (runProcess, waitForProcess)
3939
import System.Exit (ExitCode(..))
4040

4141
-- |Create a source distribution.
4242
sdist :: SDistFlags -> SDistExFlags -> IO ()
4343
sdist flags exflags = do
44-
pkg <- return . flattenPackageDescription
45-
=<< readPackageDescription verbosity
46-
=<< defaultPackageDesc verbosity
44+
pkg <- liftM flattenPackageDescription
45+
(readPackageDescription verbosity =<< defaultPackageDesc verbosity)
4746
let withDir = if not needMakeArchive then (\f -> f tmpTargetDir)
4847
else withTempDirectory verbosity tmpTargetDir "sdist."
4948
-- 'withTempDir' fails if we don't create 'tmpTargetDir'...

0 commit comments

Comments
 (0)