Setting up a development environment
Installing an editor
Haskell development is well-supported by many popular editors such as Visual Studio Code, Sublime Text, vim / Neovim, Atom, Emacs, and others. If you do not have a preexisting preference of editor, then we recommend using Visual Studio Code to get started. Visual Studio Code is easy to set up for Haskell development and is currently the most popular editor overall.
To see installation instructions for a given editor listed above, visit the corresponding provided link. In the case of Emacs, it is fairly common to use an Emacs distribution (basically a collection of packages bundled with base Emacs) to reduce the effort required to set up Emacs such as Spacemacs, Doom Emacs, Emacs Prelude, or Purcell Emacs, among many others.
Installing the Haskell Language Server
The Haskell language server (HLS) implements the Language Server Protocol (LSP) for the Haskell language. HSL can be very useful for development when paired with an editor with support for LSP (such as one of the editors mentioned above) since it provides immediate feedback from the compiler, among other features.
You can use ghcup
to install whatever its current recommended version of HLS is.
ghcup install hls
You may already have installed HLS, in which case you can skip this step (however there is no harm in running it). |
Configuring your editor to utilize HLS
Please see Configuring your editor in the HLS documentation for instructions on how to configure your editor to utilize HLS.
A note on using HLS in multi-project repositories
Since the asclepias repository has a multiple project layout
(i.e. hasklepias-core
, hasklepias-main
, etc.),
it may not be obvious how to set up HLS.
For example, should you run one server that serves all of the files across the various projects,
or should you run one server per project?
To resolve this issue,
the asclepias repository provides a file hie.yaml
in the repository root
that specifies the HLS configuration for all of the projects in the repository
(see the hie-bios documentation for details).
As a result of this setup, you can run a single HLS server
that will work correctly for all of the projects in the repository.
If you are asked by your editor to specify what directory to start HLS in
then you can use the repository root directory.
Some editors may automatically detect the hie-bios configuration setup in the repository and just "do the right thing." If you open a Haskell file in your editor and the LSP client seems to be working properly then you are probably good-to-go.