Monday, February 01, 2016

New HLint version and API features

Summary: In the new version of HLint, errors are warnings and warnings are suggestions. I plan to remove the old API very soon.

I've just released a new version of HLint, the tool for suggesting hints to improve your Haskell code. This version comes with two big changes.

Firstly, hints have been reclassified in severity. What used to be errors are now warnings, and hints that used to be warnings are now suggestions. As people have mentioned in the past, nothing HLint suggested was really an error, and now HLint matches that.

Secondly, there is now an hlint API entry point in Language.Haskell.HLint3 which captures the pattern of running HLint with command-line arguments, but in process as a library. With that, I don't think there are any API patterns that are better captured by the Language.Haskell.HLint API. If no one contacts me with issues, I will be making the module Language.Haskell.HLint a copy of Language.Haskell.HLint3 in the next release.

This release (like all minor releases) fixes a few bugs and adds a few new features. As a few random examples, HLint now warns on a redundant DefaultSignatures language extension, suggests fmap in preference to liftM and warns when otherwise is used as a pattern variable. There is a complete change log in the repo.


Clément (@cpitclaudel) said...

Exciting update! Do we need to update the flycheck checker? It currently reads as follows:

(flycheck-define-checker haskell-hlint
"A Haskell style checker using hlint.
See URL `'."
:command ("hlint"
(option-list "-X" flycheck-hlint-language-extensions concat)
(option-list "-i=" flycheck-hlint-ignore-rules concat)
(option-list "-h" flycheck-hlint-hint-packages concat)
(config-file "-h" flycheck-hlintrc)
(eval flycheck-hlint-args)
((warning line-start
(file-name) ":" line ":" column
": Warning: "
(message (one-or-more (and (one-or-more (not (any ?\n))) ?\n)))
(error line-start
(file-name) ":" line ":" column
": Error: "
(message (one-or-more (and (one-or-more (not (any ?\n))) ?\n)))
:modes (haskell-mode literate-haskell-mode))

Clément (@cpitclaudel) said...

Sorry for the broken formatting; your blog disallows pre tags.

Neil Mitchell said...

Clément: You should probably add an extra ": Suggestion: " pattern into the list. That will be forward and backward compatible. Thanks for maintaining flychecker!