Skip to content

Follow HLint suggestion: use <$> - #12015

Open
philderbeast wants to merge 28 commits into
haskell:masterfrom
cabalism:hlint/use-fmap-operator
Open

Follow HLint suggestion: use <$>#12015
philderbeast wants to merge 28 commits into
haskell:masterfrom
cabalism:hlint/use-fmap-operator

Conversation

@philderbeast

Copy link
Copy Markdown
Collaborator

See #9110. Discharges and no longer ignores HLint's "use <$>" suggestion so that this will be suggested by our CI linting.

A similar suggestion, "use fmap", was merged earlier, with #11742.

There were some cascading suggestions that I tackled individually. I'll squash commits before applying the merge label if this pull request is approved.


  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

@philderbeast
philderbeast marked this pull request as draft June 24, 2026 01:47
@philderbeast
philderbeast force-pushed the hlint/use-fmap-operator branch 6 times, most recently from 032d9c5 to c0f2629 Compare June 24, 2026 02:22
@philderbeast
philderbeast marked this pull request as ready for review June 24, 2026 02:22
@philderbeast
philderbeast force-pushed the hlint/use-fmap-operator branch from c0f2629 to d6f48d1 Compare June 26, 2026 00:13
@philderbeast
philderbeast force-pushed the hlint/use-fmap-operator branch from d6f48d1 to 388296c Compare July 1, 2026 18:35
Comment thread cabal-install/src/Distribution/Client/IndexUtils/ActiveRepos.hs Outdated
Comment thread cabal-install/src/Distribution/Client/FileMonitor.hs Outdated
Comment thread cabal-install/src/Distribution/Client/ProjectOrchestration.hs Outdated
Comment thread cabal-install/src/Distribution/Client/TargetSelector.hs Outdated
Comment thread cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs Outdated
Comment thread Cabal/src/Distribution/Simple/Program/Find.hs Outdated
Comment thread cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs Outdated
Comment thread Cabal-syntax/src/Distribution/Types/CondTree.hs Outdated
@philderbeast
philderbeast force-pushed the hlint/use-fmap-operator branch from 1834ec6 to 91914a5 Compare July 5, 2026 12:28
@philderbeast
philderbeast force-pushed the hlint/use-fmap-operator branch from e241b16 to 2a34fc8 Compare July 23, 2026 18:29
@philderbeast
philderbeast force-pushed the hlint/use-fmap-operator branch from 580079b to 37f6728 Compare July 23, 2026 19:38
runShrinker $
pure SourceRepositoryPackage
<*> shrinker srpType
(SourceRepositoryPackage <$> shrinker srpType)

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.

Is the bracket required?

s <- parsec
exc <- exception
return $ ELicense s exc
ELicense s <$> exception

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 in the business of rewriting monadic parsers in applicative style, let's not stop halfway through. Could we define simple = ELicense <$> parsec <$> exception?

P.spaces
t <- term
return (intersectVersionRanges f t)
intersectVersionRanges f <$> term

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.

Same as above, it feels confusing to switch from monadic parser style to applicative in the middle of do-block. We can rewrite this in its entirety as an applicative expression.

_ <- P.char '='
abi <- parsec
return (AbiDependency uid abi)
AbiDependency uid <$> parsec

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.

parsec = AbiDependency <$> parsec <* P.char '=' <*> parsec.

_ <- P.char ':'
mod_name <- parsec
return (Module uid mod_name)
Module uid <$> parsec

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.

Same as above, let's rewrite the entire do-block in applicative style.

a <- getWord64le
b <- getWord64le
return (Fingerprint a b)
Fingerprint a <$> getWord64le

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.

Same, binaryGetMD5 = Fingerprint <$> getWord64le <*> getWord64le

_ <- P.char '-'
os <- parsec
return (Platform arch os)
Platform arch <$> parsec

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.

Same as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants