Haskell Tooling Guide: VSCode + HIE

This post aims to compliment the PureScript Compiler Developer’s Guide with direct steps to install an IDE for Haskell and configure it for editing the PS compiler.

This post covers VSCode + HIE backend. Feel free to contribute instructions for your preferred IDE.

Install VSCode

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 were tested on 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.

10 Likes

for what it’s worth, I’ve had a terrible time with HIE (on Windows). I use VS Code and have really loved the Simple GHC (Haskell) Integration extension. It was just plug & play for me. It doesn’t do as much stuff, but if all you need is simple IDE features like showing you the types of all the functions/expressions, it’s great, and actually a joy to install and setup :slight_smile:

2 Likes