This is a DevContainer environment for Visual Studio Code, allowing automatically installing the Haskell compiler (GHC) and setting up the Haskell Language Server VS Code plugin.
Follow the Getting Started instructions to configure your Visual Studio Code and Docker to use with DevContainers.
Place the .devcontainer
directory in the root of your project, and the next time you load the project, Visual Studio Code will prompt to re-open the project in a container:
Note: building the container might take a few minutes until all dependencies have finished downloading.
Visual Studio Code supports Developing inside a Container - using a Docker image as a development environment. It automates the process of creating the container image, as well as installing additional required extensions into the editor.
Pressing Reopen in Container will perform the automated steps to launch the container, and set up the environment.
For more information and setup, read the official documentation: https://code.visualstudio.com/docs/remote/containers
The Dockerfile
contains the following:
- Stack configured with
system-ghc: true
to prevent stack from installing another GHC. - A script to install some additional tools (such as git), as well as configuring a special user
vscode
to allow access from VSCode.
The devcontainer.json
provides the following additional configurations:
- build.args:
- GHC_VERSION - Defaults to 8.10.4
- Volumes:
- vscode-haskell-stack - A volume to store ~/.stack to prevent having to fetch and rebuild dependencies
- vscode-haskell-cache - A volume to store ~/.cache for hie-bios generated files
It also has some additional configuration for VSCode. In particular, it configures the required extensions that have to be installed, and the name of the remote user (must match the one in the Dockerfile
).
Stack is preconfigured in the image to allow using system GHC. However, if you generate a new project in the DevContainer without specifying a resolver, it will attempt to choose the latest resolver compatible with your dependencies (if any have yet been defined). This means that Stack may download a newer GHC if the resolver is not compatible with the pre-installed GHC. This is undesireable since HIE and HLS have been compiled for the specific GHC version tagged. For GHC 8.6.5, the last Stack LTS available is 14.27. Currently, the 8.8.3 container can run stack new
or stack init
without any resolver arguments and use system GHC.