haskell / haskell/cabal

'cabal repl' with stack traces

Open
#7,674 8 comments 0 reactions 0 assignees View on GitHub
Cabal: cmd/repl can-workaround type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

I've been looking around for a set of flags/configurations that would allow me to load my project into GHCi and have access to stack traces. So far, I found [this blog post](http://simonmar.github.io/posts/2016-02-12-Stack-traces-in-GHCi.html) that explains how to access stack traces from plain GHCi (not from `cabal repl`). I also found [this](http://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ghci.html#stack-traces-in-ghci) in the official docs - which is practically a summary of the blog post.

What I've tried so far with no success:

- Add `-fexternal-interpreter -prof` to the `ghc-options` section in my `.cabal file`
- Run `cabal repl --ghc-options="-fexternal-interpreter -prof"`. I got a warning from GHCi, but no stack traces.
- Run `cabal repl -p`. This required installing the `ghc-prof` library (I'm using Fedora).
- Run `cabal exec ghci -- -fexternal-interpreter -prof`. I got some errors related to missing files in the `new-dist` folder. Then, I recompiled with `cabal build -p`.

My project has several targets (a lib, a test suite and several executables). What I want is to load the library (the default when running `cabal repl`) and use `Debug.traceStack`. I do not care about getting stack traces from third party dependencies, I just care about what my code is doing.

Right now I'm using `HasCallStack` as a workaround, but the traces are extremely short (a single function) and it's very inconvenient to add the constraint on every function.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.