ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/refs/heads/develop/ghcup-prereleases-0.0.9.yaml
ghcup install ghc 9.14.0.20251104
ghcup set ghc 9.14.0.20251104
cabal update # make sure latest version is available
cabal install haskell-debugger-0.10.1.0 --allow-newer=base,time,containers,ghc,ghc-bignum,template-haskell --enable-executable-dynamic
hdb --version # check it is in $PATH
Search for "Haskell Debugger", an extension published by "Well-Typed" on VSCode You can also install it by following this VSCode marketplace link
Make sure that hdb and ghc version 9.14.1-rc2 is available in $PATH when VSCode is launched.
- You need to open the workspace for the project you want to debug. Here is a sample program from the testsuite:
module Main where
import Data.IntMap
import qualified Data.IntMap as IM
main = do
nn (IM.fromList [(0,345),(1,34),(46,345)])
nn (IM.fromList [(0,1)])
nn (IM.fromList [(0,2), (2,4)])
nn (IM.fromList [(0,3)])
nn :: IntMap Int -> IO ()
nn im = do
if False
then return ()
else do
nnn im
return ()
nnn :: IntMap Int -> IO ()
nnn im = do
const (return ()) imYou can save it as Main.hs in the root folder.
-
You need to create a launch.json file which indicates the entry file to the debugger. You can click on the Debugger Tab in VSCode and click "Create new launch.json" (below the green run button). Change
entryFiletoMain.hs. -
Set a breakpoint by clicking on the line number you want to stop at.
-
Click on the green run button to run the debugger.
-
You should be stopped at the line you clicked. Now you can step-next or step-into a different call. You can visualize variables in the pane and type expressions to evaluate into "Debug Console". You can also set conditional breakpoints by right clicking on the breakpoint and setting a condition which is evaluated locally.
You should be able to test the debugger on your own project. If something doesn't work, let us know so we can make sure it works in as most scenarios as possible. For multiple-home-units projects you currently need to write a hie.yaml file with:
cradle:
cabal:
component: "all"
Let us know how it goes. Happy to help you understand something better or fix bugs and add features. The issue tracker is a good place to submit bugs: https://github.com/well-typed/haskell-debugger
The
.vscode/launch.jsonshould look like this:{ "version": "0.2.0", "configurations": [ { "type": "haskell-debugger", "request": "launch", "name": "Haskell Debugger", "projectRoot": "${workspaceFolder}", "entryFile": "Main.hs", "entryPoint": "main", "entryArgs": [], "extraGhcArgs": [] } ] }Note the
"entryFile": "Main.hs",, this usually needs to be updated for your project.