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?

Javran
  • 3,006
  • 1
  • 19
  • 37
  • 1
    `Text2` isn't necessarily Haskell syntax. One example is the "Reduce duplication" warning, which says `Why not: Combine with Foo/Bar/Baz.hs:123:4` – fjh Oct 02 '14 at 13:40
  • @fjh I see, so my strategy can apply to certain suggestions, but not all of them. – Javran Oct 02 '14 at 14:50

2 Answers2

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.

Neil Mitchell
  • 8,573
  • 1
  • 24
  • 76
1

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

Neil Mitchell
  • 8,573
  • 1
  • 24
  • 76