Skip to content

Instantly share code, notes, and snippets.

@alt-romes
Last active November 21, 2025 18:19
Show Gist options
  • Select an option

  • Save alt-romes/76064e26557fd6ec2b565272a4fb0964 to your computer and use it in GitHub Desktop.

Select an option

Save alt-romes/76064e26557fd6ec2b565272a4fb0964 to your computer and use it in GitHub Desktop.
On running the Haskell debugger

Install GHC 9.14.1-rc2 (using GHCup)

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

Install haskell-debugger

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

Install VSCode extension

Search for "Haskell Debugger", an extension published by "Well-Typed" on VSCode You can also install it by following this VSCode marketplace link

Finally, fire up a project on VSCode

Make sure that hdb and ghc version 9.14.1-rc2 is available in $PATH when VSCode is launched.

  1. 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 ()) im

You can save it as Main.hs in the root folder.

  1. 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 entryFile to Main.hs.

  2. Set a breakpoint by clicking on the line number you want to stop at.

  3. Click on the green run button to run the debugger.

  4. 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.

Your own project

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

@fendor
Copy link

fendor commented Nov 19, 2025

The .vscode/launch.json should 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment