vscode 中的 Haskell(使用 WSL2),未命中断点

问题描述 投票:0回答:0

我想开始学习 haskell,vscode 似乎是一个不错的 IDE。我尝试设置它。

我尝试了以下方法:

我进入了我想要工作的目录中的WSL2(ubuntu 20.04.6),并从那里执行了

code .
。这将在给定文件夹中打开 vscode,然后我使用

创建了一个 haskell 项目
stack new my-project
cd my-project
stack setup

然后我使用

stack build
构建项目。

接下来我下载扩展haskell语言支持。 接下来,我下载扩展 haskell GHCi 调试适配器 Phoityne 并按照说明执行操作

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

最后,我进入 vscode 中的 Run and Debug 选项卡,单击 create a launch.json file 并选择 haskell-debug-adapter。这将在 .vscode 文件夹下创建 launch.json 文件

{
    // 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
        }
    ]
}

从这个文件看来

{workspaceFolder}/test/Spec.hs 是启动的入口点。该文件包含

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

我在这两行上都放置了一个断点,然后单击绿色播放按钮进行 haskell(堆栈)配置。

但是,这并没有什么作用。它只加载几秒钟,终端上没有打印任何内容,也没有命中断点。有人知道我做错了什么吗?

visual-studio-code haskell wsl-2 haskell-stack
© www.soinside.com 2019 - 2024. All rights reserved.