cabal project with multiple targets #1006
Description
I am using nix, HIE (via https://github.com/domenkozar/hie-nix) & emacs to hack on my project here: https://github.com/sboehler/beans/tree/6524a34f85b758d055eaa923fa9005463f7b91d1. My workflow is to enter a nix-shell (see shell.nix for exact config) to to use cabal new-style build commands. I also start emacs with the recommended lsp-* packages from within the nix-shell.
When I edit any Haskell file under /src (cabal's lib:beans target), all imports are correctly detected. However, when opening a file located under /app (exe:beans target) or /tests (test:test target), HIE willl not recognize imports which are not listed under the dependencies of lib:beans in beans.cabal / package.yaml. For eample, the tasty test framework is only listed as a dependency of test:test, hence HIE reports imports from tasty as unknown.
It seems that for some reasons, only dependencies for the library target in a cabal file are detected. I am not familiar with how HIE works and whether this behavior is expected. Ideally, HIE should be aware of the corresponding cabal target of a source file and use the correct dependency list.
(Edit: replaced link to project with link to specific commit where the issue is reproducible)