A modern debugger and debug adapter for Haskell — compatible with VSCode, Vim, and Emacs
All the features:
The haskell-debugger executable hdb
is a standalone application which uses
the GHC library to implement the Debug Adapter Protocol (DAP)
for Haskell.
Any editor which supports DAP can be configured to step-through
Haskell code by using the hdb
tool.
This includes VSCode, Vim and Emacs.
First, the executable must be made available in PATH
. It can be downloaded and installed from hackage with:
cabal install haskell-debugger --allow-newer=base,time,containers,ghc,ghc-bignum,template-haskell --enable-executable-dynamic
hdb
is only supported from GHC 9.14 onwards.--enable-executable-dynamic
!
Second, your editor must be taught how to launch hdb
:
Editor | Description |
---|---|
VSCode | Install the Haskell Debugger VSCode extension, select the debugger tab, and click the "Create launch.json" button followed by the green "Run" button. |
Nvim | Install the nvim-dap plugin and configure it accordingly |
Emacs | Install and configure a DAP client plugin. Do submit the instructions in a PR |
Usage varies depending on the editor. Please consult the editor documentation regarding the debugger controls, such as Debug code with Visual Studio Code
The debugger is launched with the following properties customizing the
debugging session. In VSCode, these options can be set in the
launch.json
file.
Setting | Description |
---|---|
projectRoot |
the full path to the project root; this is typically
${workspaceFolder} , a value which is interpolated by the editor
with the actual path |
entryFile |
the relative path from the project root to the file with the entry
point for execution (e.g. app/Main.hs ) |
entryPoint |
the name of the function that is called to start execution (e.g. main ) |
entryArgs |
the arguments passed to the entryPoint ; if the
entryPoint is main , these arguments are passed
as environment arguments (as in getArgs ) rather than direct
function arguments (e.g. [] ). |
extraGhcArgs |
additional flags to pass to the ghc invocation that loads the
program for debugging (e.g. [] ) |