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 that explains how to access stack traces from plain GHCi (not from cabal repl
). I also found this 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 theghc-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 theghc-prof
library (I'm using Fedora). - Run
cabal exec ghci -- -fexternal-interpreter -prof
. I got some errors related to missing files in thenew-dist
folder. Then, I recompiled withcabal 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.