Skip to content

Commit f75c320

Browse files
committed
Follow hlint suggestion: redundant lambda
- Satisfy fourmolu - Use partial type sig to avoid -XFlexibleContexts - Fixes the "Non type-variable argument" error - Import GenEntry from Codec.Archive.Tar - Styling change only, use less vertical space - Remove comment and -XScopedTypeVariables - Add unpack and unpackT - More reuse of unpackNormalFile - Renaming, unpackCheck and unpackCheckM - Move helper functions next to other helpers - Satisfy fourmolu after rebasing
1 parent ed1cbcb commit f75c320

10 files changed

Lines changed: 137 additions & 161 deletions

File tree

.hlint.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
- ignore: {name: "Redundant $!"} # 3 hints
88
- ignore: {name: "Redundant guard"} # 1 hint
99
- ignore: {name: "Redundant if"} # 6 hints
10-
- ignore: {name: "Redundant lambda"} # 16 hints
1110
- ignore: {name: "Redundant multi-way if"} # 1 hint
1211
- ignore: {name: "Redundant return"} # 7 hints
1312
- ignore: {name: "Use ++"} # 4 hints

Cabal/src/Distribution/Compat/Async.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ withAsyncNF m = inline withAsyncUsing forkIO (m >>= evaluateNF)
7272
withAsyncUsing :: (IO () -> IO ThreadId) -> IO a -> (AsyncM a -> IO b) -> IO b
7373
-- The bracket version works, but is slow. We can do better by
7474
-- hand-coding it:
75-
withAsyncUsing doFork = \action inner -> do
75+
withAsyncUsing doFork action inner = do
7676
var <- newEmptyMVar
7777
mask $ \restore -> do
7878
t <- doFork $ try (restore action) >>= putMVar var

Cabal/src/Distribution/Simple/BuildTarget.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,13 +611,13 @@ showComponentKindShort BenchKind = "bench"
611611
--
612612

613613
matchComponent1 :: [ComponentInfo] -> String -> Match BuildTarget
614-
matchComponent1 cs = \str1 -> do
614+
matchComponent1 cs str1 = do
615615
guardComponentName str1
616616
c <- matchComponentName cs str1
617617
return (BuildTargetComponent (cinfoName c))
618618

619619
matchComponent2 :: [ComponentInfo] -> String -> String -> Match BuildTarget
620-
matchComponent2 cs = \str1 str2 -> do
620+
matchComponent2 cs str1 str2 = do
621621
ckind <- matchComponentKind str1
622622
guardComponentName str2
623623
c <- matchComponentKindAndName cs ckind str2
@@ -666,7 +666,7 @@ matchComponentKindAndName cs ckind str =
666666
--
667667

668668
matchModule1 :: [ComponentInfo] -> String -> Match BuildTarget
669-
matchModule1 cs = \str1 -> do
669+
matchModule1 cs str1 = do
670670
guardModuleName str1
671671
nubMatchErrors $ do
672672
c <- tryEach cs
@@ -675,7 +675,7 @@ matchModule1 cs = \str1 -> do
675675
return (BuildTargetModule (cinfoName c) m)
676676

677677
matchModule2 :: [ComponentInfo] -> String -> String -> Match BuildTarget
678-
matchModule2 cs = \str1 str2 -> do
678+
matchModule2 cs str1 str2 = do
679679
guardComponentName str1
680680
guardModuleName str2
681681
c <- matchComponentName cs str1

Cabal/src/Distribution/Simple/GHC/Build/ExtraSources.hs

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -171,108 +171,108 @@ buildExtraSources
171171
ghcProg
172172
buildTargetDir
173173
(neededLibWays, neededFLibWay, neededExeWay)
174-
verbHandles =
175-
\PreBuildComponentInputs{buildingWhat, localBuildInfo = lbi, targetInfo} -> do
176-
let
177-
bi = componentBuildInfo (targetComponent targetInfo)
178-
verbosity = mkVerbosity verbHandles $ buildingWhatVerbosity buildingWhat
179-
clbi = targetCLBI targetInfo
180-
isIndef = componentIsIndefinite clbi
181-
mbWorkDir = mbWorkDirLBI lbi
182-
i = interpretSymbolicPath mbWorkDir
183-
sources = viewSources (targetComponent targetInfo)
184-
comp = compiler lbi
185-
platform = hostPlatform lbi
186-
tempFileOptions = commonSetupTempFileOptions $ buildingWhatCommonFlags buildingWhat
187-
runGhcProg =
188-
runGHCWithResponseFile
189-
"ghc.rsp"
190-
Nothing
191-
tempFileOptions
192-
verbosity
193-
ghcProg
194-
comp
195-
platform
196-
mbWorkDir
174+
verbHandles
175+
PreBuildComponentInputs{buildingWhat, localBuildInfo = lbi, targetInfo} = do
176+
let
177+
bi = componentBuildInfo (targetComponent targetInfo)
178+
verbosity = mkVerbosity verbHandles $ buildingWhatVerbosity buildingWhat
179+
clbi = targetCLBI targetInfo
180+
isIndef = componentIsIndefinite clbi
181+
mbWorkDir = mbWorkDirLBI lbi
182+
i = interpretSymbolicPath mbWorkDir
183+
sources = viewSources (targetComponent targetInfo)
184+
comp = compiler lbi
185+
platform = hostPlatform lbi
186+
tempFileOptions = commonSetupTempFileOptions $ buildingWhatCommonFlags buildingWhat
187+
runGhcProg =
188+
runGHCWithResponseFile
189+
"ghc.rsp"
190+
Nothing
191+
tempFileOptions
192+
verbosity
193+
ghcProg
194+
comp
195+
platform
196+
mbWorkDir
197197

198-
buildAction :: SymbolicPath Pkg File -> IO ()
199-
buildAction sourceFile = do
200-
let baseSrcOpts =
201-
componentSourceGhcOptions
202-
(verbosityLevel verbosity)
203-
lbi
204-
bi
205-
clbi
206-
buildTargetDir
207-
sourceFile
208-
vanillaSrcOpts =
209-
-- -fPIC is used in case you are using the repl
210-
-- of a dynamically linked GHC
211-
baseSrcOpts{ghcOptFPic = toFlag True}
212-
profSrcOpts =
213-
vanillaSrcOpts
214-
<> mempty
215-
{ ghcOptProfilingMode = toFlag True
216-
}
217-
sharedSrcOpts =
218-
vanillaSrcOpts
219-
<> mempty
220-
{ ghcOptFPic = toFlag True
221-
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
222-
}
223-
profSharedSrcOpts =
224-
vanillaSrcOpts
225-
<> mempty
226-
{ ghcOptProfilingMode = toFlag True
227-
, ghcOptFPic = toFlag True
228-
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
229-
}
230-
-- TODO: Placing all Haskell, C, & C++ objects in a single directory
231-
-- Has the potential for file collisions. In general we would
232-
-- consider this a user error. However, we should strive to
233-
-- add a warning if this occurs.
234-
odir = fromFlag (ghcOptObjDir vanillaSrcOpts)
198+
buildAction :: SymbolicPath Pkg File -> IO ()
199+
buildAction sourceFile = do
200+
let baseSrcOpts =
201+
componentSourceGhcOptions
202+
(verbosityLevel verbosity)
203+
lbi
204+
bi
205+
clbi
206+
buildTargetDir
207+
sourceFile
208+
vanillaSrcOpts =
209+
-- -fPIC is used in case you are using the repl
210+
-- of a dynamically linked GHC
211+
baseSrcOpts{ghcOptFPic = toFlag True}
212+
profSrcOpts =
213+
vanillaSrcOpts
214+
<> mempty
215+
{ ghcOptProfilingMode = toFlag True
216+
}
217+
sharedSrcOpts =
218+
vanillaSrcOpts
219+
<> mempty
220+
{ ghcOptFPic = toFlag True
221+
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
222+
}
223+
profSharedSrcOpts =
224+
vanillaSrcOpts
225+
<> mempty
226+
{ ghcOptProfilingMode = toFlag True
227+
, ghcOptFPic = toFlag True
228+
, ghcOptDynLinkMode = toFlag GhcDynamicOnly
229+
}
230+
-- TODO: Placing all Haskell, C, & C++ objects in a single directory
231+
-- Has the potential for file collisions. In general we would
232+
-- consider this a user error. However, we should strive to
233+
-- add a warning if this occurs.
234+
odir = fromFlag (ghcOptObjDir vanillaSrcOpts)
235235

236-
compileIfNeeded :: GhcOptions -> IO ()
237-
compileIfNeeded opts = do
238-
needsRecomp <- checkNeedsRecompilation mbWorkDir sourceFile opts
239-
when needsRecomp $ runGhcProg opts
236+
compileIfNeeded :: GhcOptions -> IO ()
237+
compileIfNeeded opts = do
238+
needsRecomp <- checkNeedsRecompilation mbWorkDir sourceFile opts
239+
when needsRecomp $ runGhcProg opts
240240

241-
createDirectoryIfMissingVerbose verbosity True (i odir)
242-
case targetComponent targetInfo of
243-
-- For libraries, we compile extra objects in the four ways: vanilla, shared, profiled and profiled shared.
244-
-- We suffix shared objects with `.dyn_o`, profiled ones with `.p_o` and profiled shared ones with `.p_dyn_o`.
245-
CLib _lib
246-
-- Unless for repl, in which case we only need the vanilla way
247-
| BuildRepl _ <- buildingWhat ->
248-
compileIfNeeded vanillaSrcOpts
249-
| otherwise ->
250-
do
251-
forM_ (neededLibWays isIndef) $ \case
252-
StaticWay -> compileIfNeeded vanillaSrcOpts
253-
DynWay -> compileIfNeeded sharedSrcOpts{ghcOptObjSuffix = toFlag "dyn_o"}
254-
ProfWay -> compileIfNeeded profSrcOpts{ghcOptObjSuffix = toFlag "p_o"}
255-
ProfDynWay -> compileIfNeeded profSharedSrcOpts{ghcOptObjSuffix = toFlag "p_dyn_o"}
256-
CFLib flib ->
257-
case neededFLibWay (withDynFLib flib) of
258-
StaticWay -> compileIfNeeded vanillaSrcOpts
259-
DynWay -> compileIfNeeded sharedSrcOpts
260-
ProfWay -> compileIfNeeded profSrcOpts
261-
ProfDynWay -> compileIfNeeded profSharedSrcOpts
262-
-- For the remaining component types (Exec, Test, Bench), we also
263-
-- determine with which options to build the objects (vanilla vs shared vs
264-
-- profiled), but predicate is the same for the three kinds.
265-
_exeLike ->
266-
case neededExeWay of
267-
StaticWay -> compileIfNeeded vanillaSrcOpts
268-
DynWay -> compileIfNeeded sharedSrcOpts
269-
ProfWay -> compileIfNeeded profSrcOpts
270-
ProfDynWay -> compileIfNeeded profSharedSrcOpts
241+
createDirectoryIfMissingVerbose verbosity True (i odir)
242+
case targetComponent targetInfo of
243+
-- For libraries, we compile extra objects in the four ways: vanilla, shared, profiled and profiled shared.
244+
-- We suffix shared objects with `.dyn_o`, profiled ones with `.p_o` and profiled shared ones with `.p_dyn_o`.
245+
CLib _lib
246+
-- Unless for repl, in which case we only need the vanilla way
247+
| BuildRepl _ <- buildingWhat ->
248+
compileIfNeeded vanillaSrcOpts
249+
| otherwise ->
250+
do
251+
forM_ (neededLibWays isIndef) $ \case
252+
StaticWay -> compileIfNeeded vanillaSrcOpts
253+
DynWay -> compileIfNeeded sharedSrcOpts{ghcOptObjSuffix = toFlag "dyn_o"}
254+
ProfWay -> compileIfNeeded profSrcOpts{ghcOptObjSuffix = toFlag "p_o"}
255+
ProfDynWay -> compileIfNeeded profSharedSrcOpts{ghcOptObjSuffix = toFlag "p_dyn_o"}
256+
CFLib flib ->
257+
case neededFLibWay (withDynFLib flib) of
258+
StaticWay -> compileIfNeeded vanillaSrcOpts
259+
DynWay -> compileIfNeeded sharedSrcOpts
260+
ProfWay -> compileIfNeeded profSrcOpts
261+
ProfDynWay -> compileIfNeeded profSharedSrcOpts
262+
-- For the remaining component types (Exec, Test, Bench), we also
263+
-- determine with which options to build the objects (vanilla vs shared vs
264+
-- profiled), but predicate is the same for the three kinds.
265+
_exeLike ->
266+
case neededExeWay of
267+
StaticWay -> compileIfNeeded vanillaSrcOpts
268+
DynWay -> compileIfNeeded sharedSrcOpts
269+
ProfWay -> compileIfNeeded profSrcOpts
270+
ProfDynWay -> compileIfNeeded profSharedSrcOpts
271271

272-
-- build any sources
273-
if null sources || componentIsIndefinite clbi
274-
then return mempty
275-
else do
276-
info verbosity ("Building " ++ description ++ "...")
277-
traverse_ buildAction sources
278-
return (toNubListR sources)
272+
-- build any sources
273+
if null sources || componentIsIndefinite clbi
274+
then return mempty
275+
else do
276+
info verbosity ("Building " ++ description ++ "...")
277+
traverse_ buildAction sources
278+
return (toNubListR sources)

Cabal/src/Distribution/Simple/SrcDist.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ filterAutogenModules pkg_descr0 =
429429
}
430430
pathsModule = autogenPathsModuleName pkg_descr0
431431
packageInfoModule = autogenPackageInfoModuleName pkg_descr0
432-
filterFunction bi = \mn ->
432+
filterFunction bi mn =
433433
mn /= pathsModule
434434
&& mn /= packageInfoModule
435435
&& notElem mn (autogenModules bi)

cabal-install-solver/src/Distribution/Solver/Modular/Preference.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,21 @@ enforcePackageConstraints pcs = go
254254
go (PChoiceF qpn@(Q _ pn) rdm gr ts) =
255255
let c = varToConflictSet (P qpn)
256256
-- compose the transformation functions for each of the relevant constraint
257-
g = \ (POption i _) -> foldl (\ h pc -> h . processPackageConstraintP qpn c i pc)
257+
g (POption i _) = foldl (\ h pc -> h . processPackageConstraintP qpn c i pc)
258258
id
259259
(M.findWithDefault [] pn pcs)
260260
in PChoiceF qpn rdm gr (W.mapWithKey g ts)
261261
go (FChoiceF qfn@(FN qpn@(Q _ pn) f) rdm gr tr m d ts) =
262262
let c = varToConflictSet (F qfn)
263263
-- compose the transformation functions for each of the relevant constraint
264-
g = \ b -> foldl (\ h pc -> h . processPackageConstraintF qpn f c b pc)
264+
g b = foldl (\ h pc -> h . processPackageConstraintF qpn f c b pc)
265265
id
266266
(M.findWithDefault [] pn pcs)
267267
in FChoiceF qfn rdm gr tr m d (W.mapWithKey g ts)
268268
go (SChoiceF qsn@(SN qpn@(Q _ pn) f) rdm gr tr ts) =
269269
let c = varToConflictSet (S qsn)
270270
-- compose the transformation functions for each of the relevant constraint
271-
g = \ b -> foldl (\ h pc -> h . processPackageConstraintS qpn f c b pc)
271+
g b = foldl (\ h pc -> h . processPackageConstraintS qpn f c b pc)
272272
id
273273
(M.findWithDefault [] pn pcs)
274274
in SChoiceF qsn rdm gr tr (W.mapWithKey g ts)

cabal-install/src/Distribution/Client/TargetSelector.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ guardPackageFile _ (FileStatusExistsFile file)
20822082
guardPackageFile str _ = matchErrorExpected "package .cabal file" str
20832083

20842084
matchPackage :: [KnownPackage] -> String -> FileStatus -> Match KnownPackage
2085-
matchPackage pinfo = \str fstatus ->
2085+
matchPackage pinfo str fstatus =
20862086
orNoThingIn "project" "" $
20872087
matchPackageName pinfo str
20882088
</> ( matchPackageNameUnknown str
@@ -2091,7 +2091,7 @@ matchPackage pinfo = \str fstatus ->
20912091
)
20922092

20932093
matchPackageName :: [KnownPackage] -> String -> Match KnownPackage
2094-
matchPackageName ps = \str -> do
2094+
matchPackageName ps str = do
20952095
guard (validPackageName str)
20962096
orNoSuchThing
20972097
"package"

cabal-install/tests/UnitTests/Distribution/Client/FetchUtils.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ testHttp = withFakeRepoCtxt get200 $ \repoCtxt repo -> do
7878
pkgId' @?= pkgId
7979
_ -> assertFailure $ "expected RepoTarballPackage, got " ++ show res
8080
where
81-
get200 = \_uri -> return 200
81+
get200 _uri = return 200
8282

8383
testGetInterrupt :: Assertion
8484
testGetInterrupt = testGetAny UserInterrupt

0 commit comments

Comments
 (0)