usethetypes#1: VSCode and Intero
In this video, we’ll assume that you’ve already installed Haskell Stack and that now you’d like an editor and some nice Haskell IDE integration. Currently, my preferred editor is Visual Studio Code. In this video, I’ll take you through installing VSCode as well as Haskero, a VSCode extension which provides Haskell IDE features based on the Intero package.
Step 1: Install Intero using Haskell Stack
cd ~/src/hello-world stack exec which intero stack build intero
This may fail on a clean Ubuntu installation due to missing external/native packages. Stack is a great tool for managing projects, dependencies and sandboxes but does not currently take care of installing system-wide native libraries for you.
In my case, we see a linker error referring to
-ltinfo. This is
mentioned in this issue in Intero’s GitHub issue
tracker. We need to install
libtinfo-dev. Note that the equivalent packages on other Linux distributions as well
as macOS and Windows will have slightly different names:
sudo apt-get install libtinfo-dev stack build intero stack exec which intero
Step 2: Install Haskero extension in VSCode
From your project directory, restart VSCode:
cd ~/src/hello-world code .
From the Extensions panel, search for “Haskero”, click on “Haskero: A full featured Haskell IDE” and click “Install”. You may need to restart VSCode at some point.
Step 3: Use Haskero features
With Haskero, you can now right-click on Haskell symbols. Open up
src/Main.hs and right-click on
putStrLn, for example.
In addition to the standard context menu commands, Haskero adds the following:
- “Go to Definition”
- “Peek Definition”
- “Find All References”
- “Rename Symbol”
It also provides red squigglies or underlines and tooltips with compiler errors as well as program issues in the “Problems” tab.