Haskell Tooling Guide: VSCode + HIE

This post aims to compliment the PureScript Compiler Developer’s Guide with a direct set of instructions for getting an IDE setup for Haskell development.

Here are instructions for getting VSCode + HIE backend configured.

Feel free to contribute instructions for your preferred IDE.

Install IDE

Install VSCode and the vscode-hie-server extension.

Setup HIE

This needs to be built from source. You should also take a look at the readme to check for any OS-specific instructions. These steps for for Ubuntu 20.04.

Clone the code:

git clone https://github.com/haskell/haskell-ide-engine --recurse-submodules
cd haskell-ide-engine

Find the GHC version that your branch of the PureScript compiler is using. This requires navigating to the compiler’s source directory and running:

$ stack ghc -- --version
The Glorious Glasgow Haskell Compilation System, version 8.6.5

Note that this version will likely be different if this command is run from another location, such as your home directory.

Then, back in the haskell-ide-engine source directory, install for that version of the compiler. For example:

stack ./install.hs hie-8.6.5

This command will take a while to complete.

You can then optionally generate a Hoogle database to provide pop-up documentation when hovering over a symbol in VSCode. Run this command from the same haskell-ide-engine directory.

stack --stack-yaml=stack-8.6.5.yaml exec hoogle generate

Other Tools

Optionally install hlint for warnings/errors, apply-refact for quick-fix suggestions, and brittany for code formatting. If these tools are installed, then their additional functionality will be picked-up by the VSCode extension.

stack install hlint apply-refact brittany

Running VSCode

Then launch VSCode from the root of the PureScript compiler directory.

cd <purescript compiler directory>
code .

You can read more about the available extension features here.

9 Likes