I am using Dante mode in Emacs for haskell.

It works great, but when in test files, it reports imports as missing / hidden.

Cause of this is that Dante is not aware that it should load appropriate packages for the test suite target, and instead loads the packages for library.

Solution is to create .dir-local.el in the directory where the test suite is and to put the line ((haskell-mode . ((dante-target . "--test")))) into it. This tells Dante to use test suite target.

Same can be done for the other targets if needed (lib, app, benchmark …).

I found this solution in one of Dante’s issues: https://github.com/jyp/dante/issues/89 , so check it for more details.