Skip to content
Open
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
1 change: 0 additions & 1 deletion .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
- ignore: {name: "Redundant return"} # 7 hints
- ignore: {name: "Use ++"} # 4 hints
- ignore: {name: "Use :"} # 30 hints
- ignore: {name: "Use <$>"} # 83 hints
- ignore: {name: "Use Down"} # 3 hints
- ignore: {name: "Use camelCase"} # 92 hints
- ignore: {name: "Use const"} # 36 hints
Expand Down
3 changes: 1 addition & 2 deletions Cabal-syntax/src/Distribution/Backpack.hs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ instance Parsec OpenModule where
parsecOpenModule = do
uid <- parsec
_ <- P.char ':'
mod_name <- parsec
return (OpenModule uid mod_name)
OpenModule uid <$> parsec

parsecModuleVar = do
_ <- P.char '<'
Expand Down
4 changes: 2 additions & 2 deletions Cabal-syntax/src/Distribution/InstalledPackageInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ showFullInstalledPackageInfo = P.showFields (const NoComment) . prettyFieldGramm
-- Just "maintainer: Tester"
showInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
showInstalledPackageInfoField fn =
fmap (\g -> Disp.render . ppField fn . g) $ fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)
(\g -> Disp.render . ppField fn . g) <$> fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)

showSimpleInstalledPackageInfoField :: String -> Maybe (InstalledPackageInfo -> String)
showSimpleInstalledPackageInfoField fn =
fmap (Disp.renderStyle myStyle .) $ fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)
(Disp.renderStyle myStyle .) <$> fieldDescrPretty ipiFieldGrammar (toUTF8BS fn)
where
myStyle = Disp.style{Disp.mode = Disp.LeftMode}

Expand Down
3 changes: 1 addition & 2 deletions Cabal-syntax/src/Distribution/SPDX/LicenseExpression.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ instance Parsec LicenseExpression where

simple = do
s <- parsec
exc <- exception
return $ ELicense s exc
ELicense s <$> exception

exception = P.optional $ P.try (spaces1 *> P.string "WITH" *> spaces1) *> parsec

Expand Down
3 changes: 1 addition & 2 deletions Cabal-syntax/src/Distribution/System.hs
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ instance Parsec Platform where
parsec = do
arch <- parsecDashlessArch
_ <- P.char '-'
os <- parsec
return (Platform arch os)
Platform arch <$> parsec
where
parsecDashlessArch = classifyArch Strict <$> dashlessIdent

Expand Down
3 changes: 1 addition & 2 deletions Cabal-syntax/src/Distribution/Types/AbiDependency.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ instance Parsec AbiDependency where
parsec = do
uid <- parsec
_ <- P.char '='
abi <- parsec
return (AbiDependency uid abi)
AbiDependency uid <$> parsec

instance Binary AbiDependency
instance Structured AbiDependency
Expand Down
4 changes: 1 addition & 3 deletions Cabal-syntax/src/Distribution/Types/CondTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ traverseCondTreeV f (CondNode a ifs) =
-- | @@Traversal@@ for the data
traverseCondBranchA :: L.Traversal (CondBranch v a) (CondBranch v b) a b
traverseCondBranchA f (CondBranch cnd t me) =
pure (CondBranch cnd)
<*> traverseCondTreeA f t
<*> traverse (traverseCondTreeA f) me
CondBranch cnd <$> traverseCondTreeA f t <*> traverse (traverseCondTreeA f) me

-- | @@Traversal@@ for the variables
traverseCondBranchV :: L.Traversal (CondBranch v a) (CondBranch w a) v w
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ allCondTrees
-> GenericPackageDescription
-> f GenericPackageDescription
allCondTrees f (GenericPackageDescription p v a1 x1 x2 x3 x4 x5 x6) =
pure (GenericPackageDescription p)
<*> pure v
<*> pure a1
<*> traverse f x1
GenericPackageDescription p v a1
<$> traverse f x1
<*> (traverse . _2) f x2
<*> (traverse . _2) f x3
<*> (traverse . _2) f x4
Expand Down
3 changes: 1 addition & 2 deletions Cabal-syntax/src/Distribution/Types/Mixin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ instance Parsec Mixin where
versionGuardMultilibs
LSubLibName <$> parsec
P.spaces
incl <- parsec
return (mkMixin pn ln incl)
mkMixin pn ln <$> parsec

versionGuardMultilibs :: CabalParsing m => m ()
versionGuardMultilibs = do
Expand Down
3 changes: 1 addition & 2 deletions Cabal-syntax/src/Distribution/Types/Module.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ instance Parsec Module where
parsec = do
uid <- parsec
_ <- P.char ':'
mod_name <- parsec
return (Module uid mod_name)
Module uid <$> parsec

instance NFData Module where
rnf (Module uid mod_name) = rnf uid `seq` rnf mod_name
10 changes: 5 additions & 5 deletions Cabal-syntax/src/Distribution/Types/PackageDescription.hs
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,15 @@ enabledComponents pkg enabled = filter (componentEnabled enabled) $ pkgBuildable

lookupComponent :: PackageDescription -> ComponentName -> Maybe Component
lookupComponent pkg (CLibName name) =
fmap CLib $ find ((name ==) . libName) (allLibraries pkg)
CLib <$> find ((name ==) . libName) (allLibraries pkg)
lookupComponent pkg (CFLibName name) =
fmap CFLib $ find ((name ==) . foreignLibName) (foreignLibs pkg)
CFLib <$> find ((name ==) . foreignLibName) (foreignLibs pkg)
lookupComponent pkg (CExeName name) =
fmap CExe $ find ((name ==) . exeName) (executables pkg)
CExe <$> find ((name ==) . exeName) (executables pkg)
lookupComponent pkg (CTestName name) =
fmap CTest $ find ((name ==) . testName) (testSuites pkg)
CTest <$> find ((name ==) . testName) (testSuites pkg)
lookupComponent pkg (CBenchName name) =
fmap CBench $ find ((name ==) . benchmarkName) (benchmarks pkg)
CBench <$> find ((name ==) . benchmarkName) (benchmarks pkg)

getComponent :: PackageDescription -> ComponentName -> Component
getComponent pkg cname = fromMaybe missingComponent (lookupComponent pkg cname)
Expand Down
6 changes: 2 additions & 4 deletions Cabal-syntax/src/Distribution/Types/VersionRange/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,7 @@ versionRangeParser digitParser csv = expr
_ <- P.string "||"
checkOp
P.spaces
e <- expr
return (unionVersionRanges t e)
unionVersionRanges t <$> expr
<|> return t
term = do
f <- factor
Expand All @@ -374,8 +373,7 @@ versionRangeParser digitParser csv = expr
_ <- P.string "&&"
checkOp
P.spaces
t <- term
return (intersectVersionRanges f t)
intersectVersionRanges f <$> term
<|> return f
factor = parens expr <|> prim

Expand Down
3 changes: 1 addition & 2 deletions Cabal-syntax/src/Distribution/Utils/MD5.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ binaryPutMD5 (Fingerprint a b) = do
binaryGetMD5 :: Get MD5
binaryGetMD5 = do
a <- getWord64le
b <- getWord64le
return (Fingerprint a b)
Fingerprint a <$> getWord64le

-- |
--
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/GHC/Build/Link.hs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ linkFLib flib bi lbi linkerOpts (way, buildOpts) targetDir runGhcProg = do
{ ghcOptLinkNoHsMain = toFlag True
, ghcOptShared = toFlag True
, ghcOptFPic = toFlag True
, ghcOptLinkModDefFiles = toNubListR $ fmap getSymbolicPath $ foreignLibModDefFile flib
, ghcOptLinkModDefFiles = toNubListR (getSymbolicPath <$> foreignLibModDefFile flib)
}
ForeignLibNativeStatic ->
-- this should be caught by buildFLib
Expand Down
2 changes: 1 addition & 1 deletion Cabal/src/Distribution/Simple/GHCJS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
, ghcOptLinkLibs = rtsOptLinkLibs
, ghcOptLinkLibPath = toNubListR $ map makeSymbolicPath $ rtsLibPaths rtsInfo
, ghcOptFPic = toFlag True
, ghcOptLinkModDefFiles = toNubListR $ fmap getSymbolicPath $ gbuildModDefFiles bm
, ghcOptLinkModDefFiles = toNubListR (getSymbolicPath <$> gbuildModDefFiles bm)
}
ForeignLibNativeStatic ->
-- this should be caught by buildFLib
Expand Down
80 changes: 40 additions & 40 deletions Cabal/src/Distribution/Simple/InstallDirs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ import qualified Prelude
import Foreign
import Foreign.C
#endif

-- ---------------------------------------------------------------------------
-- Installation directories

Expand Down Expand Up @@ -208,46 +207,47 @@ defaultInstallDirs' False comp userInstall _hasLibs = do
case buildOS of
Windows -> return "$prefix"
_ -> return ("$prefix" </> "lib")
return $
fmap toPathTemplate $
InstallDirs
{ prefix = installPrefix
, bindir = "$prefix" </> "bin"
, libdir = installLibDir
, libsubdir = case comp of
UHC -> "$pkgid"
_other -> "$abi" </> "$libname"
, dynlibdir =
"$libdir" </> case comp of
return
( toPathTemplate
<$> InstallDirs
{ prefix = installPrefix
, bindir = "$prefix" </> "bin"
, libdir = installLibDir
, libsubdir = case comp of
UHC -> "$pkgid"
_other -> "$abi"
, bytecodelibdir = "$libdir" </> "$libsubdir"
, libexecsubdir = "$abi" </> "$pkgid"
, flibdir = "$libdir"
, libexecdir = case buildOS of
Windows -> "$prefix" </> "$libname"
Haiku -> "$libdir"
_other -> "$prefix" </> "libexec"
, includedir = case buildOS of
Haiku -> "$prefix" </> "develop" </> "headers"
_other -> "$libdir" </> "$libsubdir" </> "include"
, datadir = case buildOS of
Windows -> "$prefix"
Haiku -> "$prefix" </> "data"
_other -> "$prefix" </> "share"
, datasubdir = "$abi" </> "$pkgid"
, docdir = case buildOS of
Haiku -> "$prefix" </> "documentation"
_other -> "$datadir" </> "doc" </> "$abi" </> "$pkgid"
, mandir = case buildOS of
Haiku -> "$docdir" </> "man"
_other -> "$datadir" </> "man"
, htmldir = "$docdir" </> "html"
, haddockdir = "$htmldir"
, sysconfdir = case buildOS of
Haiku -> "boot" </> "system" </> "settings"
_other -> "$prefix" </> "etc"
}
_other -> "$abi" </> "$libname"
, dynlibdir =
"$libdir" </> case comp of
UHC -> "$pkgid"
_other -> "$abi"
, bytecodelibdir = "$libdir" </> "$libsubdir"
, libexecsubdir = "$abi" </> "$pkgid"
, flibdir = "$libdir"
, libexecdir = case buildOS of
Windows -> "$prefix" </> "$libname"
Haiku -> "$libdir"
_other -> "$prefix" </> "libexec"
, includedir = case buildOS of
Haiku -> "$prefix" </> "develop" </> "headers"
_other -> "$libdir" </> "$libsubdir" </> "include"
, datadir = case buildOS of
Windows -> "$prefix"
Haiku -> "$prefix" </> "data"
_other -> "$prefix" </> "share"
, datasubdir = "$abi" </> "$pkgid"
, docdir = case buildOS of
Haiku -> "$prefix" </> "documentation"
_other -> "$datadir" </> "doc" </> "$abi" </> "$pkgid"
, mandir = case buildOS of
Haiku -> "$docdir" </> "man"
_other -> "$datadir" </> "man"
, htmldir = "$docdir" </> "html"
, haddockdir = "$htmldir"
, sysconfdir = case buildOS of
Haiku -> "boot" </> "system" </> "settings"
_other -> "$prefix" </> "etc"
}
)

-- ---------------------------------------------------------------------------
-- Converting directories, absolute or prefix-relative
Expand Down
4 changes: 1 addition & 3 deletions Cabal/src/Distribution/Simple/Program/Find.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ programSearchPathAsPATHVar searchpath = do
return (intercalate [searchPathSeparator] (concat ess))
where
getEntries (ProgramSearchPathDir dir) = return [dir]
getEntries ProgramSearchPathDefault = do
env <- getEnvironment
return (maybe [] splitSearchPath (lookup "PATH" env))
getEntries ProgramSearchPathDefault = maybe [] splitSearchPath . lookup "PATH" <$> getEnvironment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are changing it anyway, let's use lookupEnv.


-- | Get the system search path. On Unix systems this is just the @$PATH@ env
-- var, but on windows it's a bit more complicated.
Expand Down
7 changes: 3 additions & 4 deletions Cabal/src/Distribution/Simple/Register.hs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ abiHash
abiHash verbosity pkg distPref lbi lib clbi =
case compilerFlavor comp of
GHC -> do
fmap mkAbiHash $ GHC.libAbiHash verbosity pkg lbi' lib clbi
mkAbiHash <$> GHC.libAbiHash verbosity pkg lbi' lib clbi
GHCJS -> do
fmap mkAbiHash $ GHCJS.libAbiHash verbosity pkg lbi' lib clbi
mkAbiHash <$> GHCJS.libAbiHash verbosity pkg lbi' lib clbi
_ -> return (mkAbiHash "")
where
comp = compiler lbi
Expand Down Expand Up @@ -713,8 +713,7 @@ relocatableInstalledPackageInfo pkg abi_hash lib lbi clbi pkgroot =
bi = libBuildInfo lib

installDirs =
fmap (("${pkgroot}" </>) . shortRelativePath (getSymbolicPath pkgroot)) $
absoluteComponentInstallDirs pkg lbi (componentUnitId clbi) NoCopyDest
("${pkgroot}" </>) . shortRelativePath (getSymbolicPath pkgroot) <$> absoluteComponentInstallDirs pkg lbi (componentUnitId clbi) NoCopyDest

-- -----------------------------------------------------------------------------
-- Unregistration
Expand Down
6 changes: 2 additions & 4 deletions Cabal/src/Distribution/Simple/Setup/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,7 @@ parsecPromisedComponent = do
then LMainLibName
else LSubLibName ucn
_ <- P.char '='
cid <- parsec
return $ PromisedComponent pn ln cid
PromisedComponent pn ln <$> parsec

prettyPromisedComponent :: PromisedComponent -> String
prettyPromisedComponent (PromisedComponent pn cn cid) =
Expand All @@ -946,8 +945,7 @@ parsecGivenComponent = do
then LMainLibName
else LSubLibName ucn
_ <- P.char '='
cid <- parsec
return $ GivenComponent pn ln cid
GivenComponent pn ln <$> parsec

prettyGivenComponent :: GivenComponent -> String
prettyGivenComponent (GivenComponent pn cn cid) =
Expand Down
4 changes: 1 addition & 3 deletions Cabal/src/Distribution/Simple/SetupHooks/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ rulesExceptionMessage = \case
showCycle :: (RuleBinary, [Graph.Tree RuleBinary]) -> String
showCycle (r, rs) =
unlines . map (" " ++) . lines $
Tree.drawTree $
fmap show $
Tree.Node r rs
Tree.drawTree (show <$> Tree.Node r rs)
CantFindSourceForRuleDependencies _r deps ->
unlines $
("Pre-build rules: can't find source for rule " ++ what ++ ":")
Expand Down
6 changes: 3 additions & 3 deletions Cabal/src/Distribution/Simple/SrcDist.hs
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ listPackageSources' verbosity rip mbWorkDir pkg_descr pps =
. withAllLib
$ \l -> do
let lbi = libBuildInfo l
incls = fmap getSymbolicPath $ filter (`notElem` autogenIncludes lbi) (installIncludes lbi)
incls = getSymbolicPath <$> filter (`notElem` autogenIncludes lbi) (installIncludes lbi)
relincdirs = fmap getSymbolicPath $ sameDirectory : mapMaybe symbolicPathRelative_maybe (includeDirs lbi)
traverse (fmap (makeSymbolicPath . snd) . findIncludeFile verbosity cwd relincdirs) incls
, -- Setup script, if it exists.
fmap (maybe [] (\f -> [makeSymbolicPath f])) $ findSetupFile cwd
maybe [] (\f -> [makeSymbolicPath f]) <$> findSetupFile cwd
, -- SetupHooks script, if it exists.
fmap (maybe [] (\f -> [makeSymbolicPath f])) $ findSetupHooksFile cwd
maybe [] (\f -> [makeSymbolicPath f]) <$> findSetupHooksFile cwd
, -- The .cabal file itself.
fmap (\d -> [d]) (coerceSymbolicPath . relativeSymbolicPath <$> tryFindPackageDesc verbosity mbWorkDir)
]
Expand Down
11 changes: 5 additions & 6 deletions Cabal/src/Distribution/Simple/Test/LibV09.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,12 @@ runTest verbHandles pkg_descr lbi clbi hpcMarkupInfo flags suite = do
-- Generate TestSuiteLog from executable exit code and a machine-
-- readable test log
suiteLog <-
fmap
( \s ->
(\l -> l{logFile = finalLogName l})
. fromMaybe (error $ "panic! read @TestSuiteLog " ++ show s)
$ readMaybe s -- TODO: eradicateNoParse
( \s ->
(\l -> l{logFile = finalLogName l})
. fromMaybe (error $ "panic! read @TestSuiteLog " ++ show s)
$ readMaybe s -- TODO: eradicateNoParse
)
$ readFile tempLog
<$> readFile tempLog

-- Write summary notice to log file indicating start of test suite
appendFile (logFile suiteLog) $ summarizeSuiteStart testName'
Expand Down
Loading
Loading