Getting incorrect import errors using ALE linter for Haskell files

Viewed 323

I am using ALE to lint my Haskell files in vim. ALE detects an import error for any package that did not come with the Haskell platform. I am still able to run cabal repl and have these packages imported properly. I then am able to load the files that have the errors into the repl which proves to me that I have indeed taken the proper steps for using these packages.

Within the files I am given proper feedback when using functions from these packages. I have of course specified these imports in the build-depends portion my .cabal file.

It is very annoying having my error messages clogged up with unrecognized imports.

Here is a copy of notable lines in my .vimrc file.

1 Answers

The problem is one of the linters is not aware of cabal. The issue is well documented here. When you use ALE and do not specify which linters you want to use, ALE goes ahead and uses all of them.

Here is a list of the linters that ALE automatically gives you for Haskell files: [cabal_ghc, ghc, ghc_mod, hdevtools, hie, hlint, stack_build, stack_ghc]

The problematic linter in this case is ghc. To fix the error go ahead and add this line to your .vimrc file:

let g:ale_linters = {'haskell': ['cabal_ghc', 'ghc-mod', 'hdevtools', 'hie', 'hlint', 'stack_build', 'stack_ghc']}

You can use whatever linters you like from this list.

Related