phoityne / hdx4vsc

Haskell Debugger Extension for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=phoityne.phoityne-vscode
BSD 3-Clause "New" or "Revised" License
50 stars 9 forks source link

Features

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

NAME REQUIRED OR OPTIONAL DEFAULT SETTING DESCRIPTION
startup required ${workspaceRoot}/test/Spec.hs debug startup file, will be loaded automatically.
startupFunc optional "" (empty string) debug startup function, will be run instead of main function.
startupArgs optional "" (empty string) arguments for startup function. set as string type.
stopOnEntry required false stop or not after debugger launched.
mainArgs optional "" (empty string) main arguments.
ghciPrompt required H>>= ghci command prompt string.
ghciInitialPrompt optional "Prelude> " initial pormpt of ghci. set it when using custom prompt. e.g. set in .ghci
ghciCmd required cabal repl -w ghci-dap --repl-no-load --builddir=${workspaceFolder/.vscode/dist-cabal-repl launch ghci command.
ghciEnv required {} Environment variables for ghci exectution.
logFile required ${workspaceRoot}/.vscode/phoityne.log internal log file.
logLevel required WARNING internal log level.
forceInspect required false Inspect scope variables force.