In this post we will walk you through a basic Haskell setup utilizing Visual Studio Code (Code Editor / IDE). We will need to install Visual Studio Code, GHC (the Glasgow Haskell Compiler), Stack(Haskell build tool), Cabal (Haskell package manager / build tool), Haskero (Visual Studio plugin that enables Haskell support), and Intero (powers the IDE like features in Haskero).
Install Visual Studio Code
Let’s start off by installing Visual Studio Code. Head to https://code.visualstudio.com/ and download the correct version for your operating system and install it.
Install Haskell Platform
When comparing Atom vs Visual Studio Code, the Slant community recommends Visual Studio Code for most people. In the question“What are the best programming text editors?” Visual Studio Code is ranked 3rd while Atom is ranked 10th. The most important reason people chose Visual Studio Code is. Code Runner is an extension that enables you to run any language’s code snippets in Visual Studio Code, with support for every popular programming language including both legacy languages and those that have gained popularity in recent years such as Clojure, Objective-C, Rust, Racket, AutoHotkey, AutoIt, and many others. Code Runner is an extension that enables you to run any language’s code snippets in Visual Studio Code, with support for every popular programming language including both legacy languages and those that have gained popularity in recent years such as Clojure, Objective-C, Rust, Racket, AutoHotkey, AutoIt, and many others. Integrated Haskell Shell. This extension integrates ghci (the interactive Haskell shell) with Visual Studio Code. This allows for auto-reloading on file change and more. To open an interactive shell, simply right click in your Haskell source file and click on Open interactive shell. Alternatively click the yellowish/orange Haskell logo in the top right corner of the editor to open/close the interactive shell,.
Next let’s go ahead and go to https://www.haskell.org/platform/ and download the latest version of the Haskell Platform for your operating system and install it (in some cases you can simply install it with your OS’s package manager). The Haskell Platform includes GHC, Cabal, and Stack (all of which we need).

Load up a terminal window (or command-prompt in windows) and try the following commands (to output the version of each) to make sure they all installed successfully.
Test for GHC’s version: ghc --version
Test for Cabal’s version: cabal --version
Test for Stack’s version: stack --version
If any of them did not install (ie. Pro checkers download for mac. the command is unrecognized) then you’ll need to go to their respective page (GHC, Cabal, Stack) and follow the instructions.
Install Haskero in Visual Studio Code
Load up Visual Studio Code. Click on the Extensions Icon of the far left (it looks like a square and is at the bottom of the icons list). Search for the Haskero Avg mac cleaner reviewyellowalley. extension. Install Haskero by clicking on the install button. Exit out of Visual Studio Code after installing Haskero.
Creating your first Haskell Project using Stack
Open up a terminal window and navigate to the directory you wish to create your haskell project in. Type the following command:
This creates a stack project named MyFirstHaskellProject
using the new-template
template. This creates a directory named MyFirstHaskellProject
in the working directory which contains the project. MyFirstHaskellProject
can be changed to whatever name desired. Different templates can be used other then the new-template
template when started a new project. The templates available can be listed out by typing stack templates
in the terminal.
Adding Intero to your Project
NOTE: you may need to upgrade your stack version & try again if the following steps fail.
Now that we’ve made a project go ahead and change directories to the MyFirstHaskellProject
directory created by stack in the terminal. First run stack setup
to setup stack. Next run stack build
to build the project. This will build the project. Now run stack build intero
to setup Intero for the project. This will allow Haskero to work correctly. Finally run code .
to load up the project in Visual Studio Code. Haskero should now be working correctly. If Haskero is having issues finding stack then you’ll need to make sure that stack is on the system path (or mess with the Haskero configuration so that it has the correct location to run stack from). You can use the command stack build --exec MyFirstHaskellProject
to compile and then run the built executable.
Looking around the newly created project
In the project you should see a few files & directories have been created for you. MyFirstHaskellProject.cabal
& stack.yaml
are filled with settings used when building the project. app/Main.hs
is the Haskell file containing the entry point of the application. The src
& test
directories are to contain source code and test code respectively.
Future projects
Here’s a list of what you need to do in the future when starting a new project.

- Run
stack new MyFirstHaskellProject new-template
to initialize a new project. - Change directories in terminal to the new project.
- Run
stack build
to do an initial build of the project. - Run
stack build intero
to add Intero to the project. - Run
code .
to start Visual Studio Code with the project loaded up.
This extension integrates ghci (the interactive Haskell shell) with Visual Studio Code. This allows for auto-reloading on file change and more.
How to use
To open an interactive shell, simply right click in your Haskell source file and click on Open interactive shell
. Alternatively click the yellowish/orange Haskell logo in the top right corner of the editor to open/close the interactive shell, or just type the commands into the command palette.
The shell runs in the vscode integrated terminal and automatically switches when you change the current file. To close the shell you can close it as you would any other terminal window by clicking the little trash can, or you can of course type :quit
into it.
Commands
Haskell: Open interactive shell
-- Open an interactive shell with the current file loaded.Haskell: Close interactive shell
-- Close the shell tied to the current file.Haskell: Toggle interactive shell
-- Self explanatory.
Requirements
Requires ghci to be installed. It probably is already if you use Haskell. If it's not and you don't know where to start the best place is probably haskell.org/downloads.
Note: Depending on how you may have installed ghci, you might have to modify the haskellShell.ghci.executablePath
setting in your vscode configuration file.
Known Issues
Visual Studio Code Haskell Code
- There are issues but I don't know about them.
Possible additions and changes
- Find a way to decouple the interactive shell from the vscode integrated terminal, so that the user can have a shell and a terminal open at the same time. I've thought about maybe using webviews, however this could be bad for performance and probably not worth the complexity.
- I want to add the ability to open a shell that is tied to multiple files. I don't know how this would be implemented design-wise.
Release History
0.0.2

- Change: Smaller icons.
- Change: No longer clear interactive shell every time file is saved.
- Fix: Files with spaces in their absolute path couldn't be opened in the interactive shell.
Visual Studio Or Visual Studio Code
0.0.1
Visual Studio Code Haskell 2020
- Initial release
