FSharpLint
FSharpLint copied to clipboard
Suggestion : Detect `[Type].map f |> [Type].choose g` and propose change to `[Type].choose (f >> g)`
Description
Since choose does a map plus filter operation, any preceding map can be coalesced, especially in the all too common case where g is the built-in function id.
Repro steps
Code looking like
foldername :: (Seq.toList symbolFolders)
|> Seq.map (I.getSymbolsByFolder filename)
|> Seq.choose id
|> Seq.tryFind (I.symbolMatch tokens)
Would-be-nice behavior
Hint to the effect that
foldername :: (Seq.toList symbolFolders)
|> Seq.choose (I.getSymbolsByFolder filename)
|> Seq.tryFind (I.symbolMatch tokens)
would be simpler
Actual behavior
No such hint
Known workarounds
Manual check/code review
Related information
FWIW, latest tool release under dotnet 7.0.302 on Windows 10 Home