Features

June 14, 2025 ยท View on GitHub

  • The source file extension must be ".hs"
  • Can not use STDIN handle while debugging.
  • Creating tasks.json.
  • Shortcut keys
    • F5 : start / continue debugging
    • F6 : show command menu
    • Shift + F6 : stop watch
    • F7 : clean & build
    • F8 : start test
    • F9 : put a breakpoint on the current line
    • Shift + F9 : put a breakpoint on the current column
    • F10 : step next
    • F11 : step into

Install

Stack

Install haskell-dap, ghci-dap, haskell-debug-adapter at once.

$ stack update
$
$ stack install haskell-dap ghci-dap haskell-debug-adapter
$
$ ghci-dap --version
[DAP][INFO] start ghci-dap-0.0.XX.0.
The Glorious Glasgow Haskell Compilation System, version X.X.X
$
$ haskell-debug-adapter --version
VERSION: haskell-debug-adapter-0.0.XX.0
$

Cabal

Install ghci-dap, haskell-debug-adapter.

$ cabal update
$
$ cabal install ghci-dap haskell-debug-adapter
$
$ haskell-debug-adapter --version
VERSION: haskell-debug-adapter-0.0.XX.0
$

Run

1. Create a project

Stack project

$ mkdir project_stack
$ cd project_stack
$
$ stack new sample --bare
$ stack test
$

Cabal project

$ mkdir project_cabal
$ cd project_cabal
$
$ cabal init
$ cabal configure
$ cabal bulid
$

2. VSCode debug setting

01_create_launch.png 02_create_launch.png

3. Select a debug configuration

Stack project

03_select_stack.png

Cabal project

03_select_cabal.png

4. Put a breakpoint

04_bp.png

5. Start debugging

05_run.png 06_break.png

Configuration

see sample files.

.vscode/launch.json

NAMEREQUIRED OR OPTIONALDEFAULT SETTINGDESCRIPTION
startuprequired${workspaceRoot}/test/Spec.hsdebug startup file, will be loaded automatically.
startupFuncoptional"" (empty string)debug startup function, will be run instead of main function.
startupArgsoptional"" (empty string)arguments for startup function. set as string type.
stopOnEntryrequiredfalsestop or not after debugger launched.
mainArgsoptional"" (empty string)main arguments.
ghciPromptrequiredH>>=ghci command prompt string.
ghciInitialPromptoptional"Prelude> "initial pormpt of ghci. set it when using custom prompt. e.g. set in .ghci
ghciCmdrequiredcabal repl -w ghci-dap --repl-no-load --builddir=${workspaceFolder/.vscode/dist-cabal-repllaunch ghci command (special value ghci-dap will use hie-bios to determine appropriate flags).
ghciEnvrequired{}Environment variables for ghci exectution.
logFilerequired${workspaceRoot}/.vscode/phoityne.loginternal log file.
logLevelrequiredWARNINGinternal log level.
forceInspectrequiredfalseInspect scope variables force.

Experimental: MCP Integration

We are currently experimenting with MCP (Model Context Protocol) support for haskell-debug-adapter.

As part of this effort, we are exploring integration with pty-mcp-server, a lightweight stdio-based MCP server that enables AI-assisted control over GHCi sessions.

We have also developed a dedicated VS Code extension named pms-vscode, which provides a frontend interface to pty-mcp-server within the editor.
Although haskell-debug-adapter and pms-vscode are implemented as independent extensions and operate separately, their collaboration may deepen in the future as part of broader efforts toward AI-driven and automated Haskell development tooling.

This integration aims to:

  • Allow AI agents to issue debug commands over MCP to the adapter
  • Provide scriptable, reproducible debugging workflows
  • Support new development and learning experiences in interactive Haskell debugging

Demo: Haskell Debugging with cabal repl

Demo haskell cabal repl
Ref : haskell cabal debug prompt

  1. Target Code Overview
    A function in MyLib.hs is selected to inspect its runtime state using cabal repl and an AI-driven debug interface.
  2. MCP Server Initialization
    The MCP server is launched to allow structured interaction between the AI and the debugging commands.
  3. Debugger Prompt and Environment Setup
    The AI receives a prompt, starts cabal repl, and loads the module to prepare for runtime inspection.
  4. Debugging Execution Begins
    The target function is executed and paused at a predefined point for runtime observation.
  5. State Inspection and Output
    Runtime values and control flow are displayed to help verify logic and observe internal behavior.
  6. Summary
    Integration with pty-msp-server enables automated runtime inspection for Haskell applications.