Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make HLint ignore parse error due to multi-way if?

Tags:

haskell

hlint

I'm using the MultiWayIf language extension. While I love HLint (I'm using version v1.8.61), unfortunately it appears that HLint is not aware of this extension, and it reports multi-way ifs as parse errors: Warning: Parse error: |

The HLint Manual (http://community.haskell.org/~ndm/darcs/hlint/hlint.htm) describes how you can use pragmas to indicate suggestions to ignore; however, this doesn't seem to work for warnings due to parse errors.

Is there any way to tell HLint to ignore the parse error warnings? Thank you!

like image 276
the-konapie Avatar asked May 18 '14 19:05

the-konapie


People also ask

What is hlint and how do I enable it?

HLint enables/disables a set of extensions designed to allow as many files to parse as possible, but sometimes you'll need to enable an additional extension (e.g. Arrows, QuasiQuotes, ...), or disable some (e.g. MagicHash) to enable your code to parse.

What happens when the parser encounters an error in XML?

If the parser encounters an error, it may load an XML document containing the error description. The code example below tries to load an XML document that is not well-formed. You can read more about well-formed XML in XML Syntax.

How do I integrate with HS-Lint?

The integration is similar to compilation-mode, allowing navigation between errors. The script is at hs-lint.el, and a copy is installed locally in the data directory. To use, add the following code to the Emacs init file: GHCi integration has been provided by Gwern Branwen.

How do I install hlint in Haskell?

HLint doesn't run any custom preprocessors, e.g. markdown-unlit or record-dot-preprocessor, so code making use of them will usually fail to parse. Installation follows the standard pattern of any Haskell library or program: type cabal update to update your local hackage database, then cabal install hlint to install HLint.


1 Answers

You can run:

hlint "--ignore=Parse error" MyFile.hs

There is a test that this invocation works in the HLint test suite.

Note that as soon as there is a parse error you won't get any other hints from the file, since HLint can't operate on a file until it is parsed.

However, if you upgrade to haskell-src-exts-1.15 or higher then reinstall HLint it should parse multi-way-if fine. If not, please report a bug.

like image 183
Neil Mitchell Avatar answered Nov 15 '22 11:11

Neil Mitchell