HaskellWiki survey of GHC debugging tools: stack traces via -prof +RTS -xc, Debug.Trace.trace, GHCi breakpoints, Hood/Hoed observation, and HAT tracing.
Key Takeaways
Enable exception stack traces with ghc -prof -fprof-auto -fprof-cafs and ./program +RTS -xc; output shows cost-centre chain to the failure site.
Debug.Trace.trace is the fastest print-debug path; guard pattern idiom lets you toggle tracing with one comment, but lazy evaluation means traces only fire when values are demanded.
GHCi debugger supports :break, :trace, :sprint, and :print for live inspection of unevaluated thunks and lazy bindings without recompilation.
Hoed annotates suspected functions, collects runtime observations, and serves a browser-based debug session – works with untransformed libraries unlike HAT.
Replacing partial functions (head, fromJust) with explicit pattern matches gives GHC enough info to report the exact source location on failure.