Debugging Help for Newbies / Positive Debugging Experience

Just had my first run-in with the Haskell debugger (mysterious Vector out-of-access crashes I couldn’t pick up with putStrLn and Debug.Trace debugging), and I think the Wiki needs some updating.

https://wiki.haskell.org/index.php?title=Debugging

I had some really cool stack traces from Haskell that helped me find out what went wrong, see:

https://paste.tomsmeding.com/RgH6YMHy

The trick seems to be found here:

https://www.reddit.com/r/haskell/comments/rh4ase/getting_cabal_to_profile/

Use cabal configure --enable-profiling, which will get it to install the profiling libraries, add the GHC-options fields, then you fall back on cabal run – myExecutable +RTS -xc, and voila!

Not sure if more experienced users find that there’s something lacking, but who’s to say that Haskell can’t do stack traces?

Also, more tips, when you’re working with Brick, vty takes control of your screen and apparently &> piping to capture stderr fails. The best way to debug here is appendFile debugging, not Debug.Trace or putStrLn. Worst case scenario, break out the unsafePerformIO on your appendFile, but there’s a trace logger on Hackage:

7 Likes

You might also consider TraceEmbrace - smart Debug.Trace

2 Likes