Haskell in vscode (with WSL2), breakpoints not being hit

197 Views Asked by At

I would like to start learning haskell and it seems vscode would be a decent IDE for this. I tried to set it up.

I tried the following :

I went into WSL2(ubuntu 20.04.6) in the directory I would like to work, and executed code . from there. This opens vscode at the given folder and then I created a haskell project using

stack new my-project
cd my-project
stack setup

Then I build the project using stack build.

Next I donwload the extension haskell language support. Next I download the extension haskell GHCi Debug Adapter Phoityne and follow the instructions by doing

stack install haskell-dap ghci-dap haskell-debug-adapter

Finally I go under the Run and Debug tab in vscode, I click on create a launch.json file and and choose haskell-debug-adapter. This creates the launch.json file under .vscode folder

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "ghc",
            "request": "launch",
            "name": "haskell(stack)",
            "internalConsoleOptions": "openOnSessionStart",
            "workspace": "${workspaceFolder}",
            "startup": "${workspaceFolder}/test/Spec.hs",
            "startupFunc": "",
            "startupArgs": "",
            "stopOnEntry": false,
            "mainArgs": "",
            "ghciPrompt": "H>>= ",
            "ghciInitialPrompt": "> ",
            "ghciCmd": "stack ghci --with-ghc=ghci-dap --test --no-load --no-build --main-is TARGET",
            "ghciEnv": {},
            "logFile": "${workspaceFolder}/.vscode/phoityne.log",
            "logLevel": "WARNING",
            "forceInspect": false
        },
        {
            "type": "ghc",
            "request": "launch",
            "name": "haskell(cabal)",
            "internalConsoleOptions": "openOnSessionStart",
            "workspace": "${workspaceFolder}",
            "startup": "${workspaceFolder}/app/Main.hs",
            "startupFunc": "",
            "startupArgs": "",
            "stopOnEntry": false,
            "mainArgs": "",
            "ghciPrompt": "H>>= ",
            "ghciInitialPrompt": "> ",
            "ghciCmd": "cabal repl -w ghci-dap --repl-no-load --builddir=${workspaceFolder}/.vscode/dist-cabal-repl",
            "ghciEnv": {},
            "logFile": "${workspaceFolder}/.vscode/phoityne.log",
            "logLevel": "WARNING",
            "forceInspect": false
        }
    ]
}

It seems from this file that

{workspaceFolder}/test/Spec.hs is the entry point of the launch. This file contains

main :: IO ()
main = putStrLn "Test suite not yet implemented"

I put a breakpoint on both these lines and then click on the green play button for the haskell (stack) configuration.

However, this doesn't do nothing. It just loads for a few seconds and nothing is printed on the terminal and no breakpoints is hit. Does anyone has an idea what I am doing wrong?

1

There are 1 best solutions below

1
K. A. Buhr On

I think I was able to duplicate your problem. When you ran:

stack install haskell-dap ghci-dap haskell-debug-adapter

it should have installed two programs ghci-dap and haskell-debug-adapter into a directory, most likely ~/.local/bin. Check that those programs are there and that that directory is in your path, specifically that you can launch ghci-dap --version and haskell-debug-adapter --version from the terminal Window within VSCode.

I found that if those programs weren't in my path, I experienced the same problem as you -- a brief "waiting" animation under the green debug arrow, and nothing else.