HLint gives suggestion how one can improve source code. However, given the nature of the suggestions, I wonder whether it's possible to automatically apply those suggestions.
Is it possible to automatically apply suggestions proposed by hlint?
HLint gives suggestion how one can improve source code. However, given the nature of the suggestions, I wonder whether it's possible to automatically apply those suggestions.
Is it possible to automatically apply suggestions proposed by hlint?
On
To complement Zeta's answer, I use some additional flags to perform the refactoring in place:
hlint --refactor --refactor-options="--inplace" path/to/your/File.hs
Sometimes you only want to apply a certain kind of hint, which can be done by passing the -o flag, e.g.:
hlint -o="Use fewer imports" --refactor --refactor-options="--inplace"
As far as I know, the suggested refactorings need to be done in a per-file basis.
You have to use
--refactorand have therefactorexecutable in your$PATH. See hlint's README for more information:Note that hlint doesn't apply transformations recursively, so additional
--refactorcould be necessary. That being said, make sure to commit/save before you applyhlint --refactorand test your code afterwards, since the changes might break your code, especially if you use Rank2Types orseq.