is there a command to apply hlint suggestions in emacs?
Asked Answered
P

2

8

I'm using flycheck and haskell-hlint in emacs when I write Haskell codes and I think it will be great if I can apply those hlint suggestions by invoking some emacs procedures instead of modifying the code manually.

If there isn't one available and in case I have to write this procedure for myself:

Is it guaranteed that hlint output is always of the following form:

Found:
  {Text1}
Why not:
  {Text2}

where {Text?} can always be parsed as a Haskell abstract syntax tree?

Pressey answered 2/10, 2014 at 13:23 Comment(2)
Text2 isn't necessarily Haskell syntax. One example is the "Reduce duplication" warning, which says Why not: Combine with Foo/Bar/Baz.hs:123:4Prostyle
@Prostyle I see, so my strategy can apply to certain suggestions, but not all of them.Pressey
N
8

HLint comes with an Emacs script hs-lint.el that does the replacement you are after, details are in the README. The script isn't officially supported by the HLint developer, but some people have had some success with it.

Separately, there are plans to provide a proper replacement feature in HLint, which if provided would be easy to integrate with Emacs. While it's always been on the back-burner, there are now people working on the necessary whitespace-aware-syntax-replacement libraries that HLint requires.

Nitrogen answered 2/10, 2014 at 21:32 Comment(1)
This is an old answer. Is there any progress on this front? (For future readers, too)Demagoguery
N
2

There is an HLint Refactor Mode building on the apply-refact tool that provides HLint replacements in Emacs.

Nitrogen answered 26/6, 2018 at 8:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.