I looked at the question @TheInternet linked, and the first answer's advice to use -fbreak-on-exception
-fbreak-on-error
and :trace
is pretty good. However I thought I'd mention two small snags I hit that are specific to this question:
- GHCi does not make
<<loop>>
exceptions, only native compiled GHC does that, and the GHCi debugger cannot trace native compiled code.
Fortunately, this can be solved by pressing ^C
to interrupt manually.
- Trying to
:trace
and then ^C
manually instead does give a debugger session, but GHCi hasn't inserted any breakpoints and so there's no context to debug!
This was also easy to fix: I just changed the first equation to x = id y
. This is enough to get GHCi to insert breakpoints. I suspect that this problem was due to the OP's code cycle containing only trivial variable equations (to quote the GHC User's Guide: "Single variables are typically not considered to be breakpoint locations (unless the variable is the right-hand-side of a function definition, lambda, or case alternative)"), and that it will not usually happen in "real" code.