Debugging IO in a package module inside GHCi

后端 未结 1 1827
有刺的猬
有刺的猬 2021-02-05 06:53

I\'m doing low-level IO (for library bindings) in Haskell and am experiencing a segfault. I would like to use GHCi\'s :break to figure out what\'s going on, but

相关标签:
1条回答
  • 2021-02-05 07:14

    Stack has some support for this. Running stack ghci --load-local-deps $TARGET will load your project and any dependencies that are in the packages field of stack.yaml, including if they're marked as extra-deps. Breakpoints will work then. You can debug a dependency in GHCi by running stack unpack $PACKAGE and adding it to packages in stack.yaml.

    This is not a panacea however. If the packages have conflicting package-global language extensions (or other dynamic flags) or module name clashes it won't work. For example, if your top-level package has default-extensions: NoImplicitPrelude and your dependencies don't, they won't have a prelude imported and will almost certainly not load. See this GHC bug.

    0 讨论(0)
提交回复
热议问题