Haskell language server doesn't recognise installed modules

Hello community.

I have installed Pandoc module through cabal using:

cabal install pandoc.

I can successfully load it in GHCI using:

:set -package pandoc

and importing with:

import Text.Pandoc

However, HLS doesn’t recognise the modules in VSC:


In my .cabal file, I added:

-- Other library packages from which modules are imported.
    build-depends:    pandoc, pandoc-types, base ^>=

but the problem persists. How can I solve this ?

Does cabal build works??. Also notice that cabal install pandoc does not make it available in the context of a project. I think cabal install pandoc will install the pandoc tool in your system.


Thank you for the reply.

Yes, it does work.

Is it possible to make it available ?


I added package split to build-depends, and I experience the same issue when I do:

import Data.List.Split

Could not load module ‘Data.List.Split’
It is a member of the hidden package ‘split-’.
You can run ‘:set -package split’ to expose it.


Please provide VSCode logs GitHub - haskell/vscode-haskell: VS Code extension for Haskell, powered by haskell-language-server.

Judging from the shown view, it seems like you might not have opened to root of your project in VSCode. Please make sure you have openend the directory that contains the .cabal file in VSCode, via “Open Folder… [Ctrl + k Ctrk + o]”.


Impressive. That was the problem. Thank you so much.

I didn’t know I had to do that so HLS can pickup dependencies in my .cabal file.

1 Like

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 :smile:

Hope it makes clearer how cabal works. (BTW most of it applies to stack)


Thank you for the clarification !

What’s the preferred way ?


I’d also recommend the GHCup first steps, which is a good introduction to Haskell tooling.