I know the problem has been solved but just to clarify. In general cabal install <package>
is a bad idea if you just want a dependency. Maybe you are thinking about python’s pip install
which makes dependencies available for your python interpreter.
cabal install
is used to install software in your system. That is building a binary executable an put it in your PATH. Think about it as apt-get install
in debian/ubuntu or executing a program.exe
file in windows.
In order to make dependencies available, you have to create a .cabal
and add dependencies to it. These dependencies will be visible only within the project!. That means if you try to use the dependencies out of the project you’ll get an error like "Could not load … ".
Because you are out of the project folder, dependencies can’t be used. HLS makes its best effort to find a .cabal
file or a package.yaml
, ut of course, you have to cd into the right folder 
Hope it makes clearer how cabal works. (BTW most of it applies to stack
)