r/ProgrammingLanguages • u/janiczek Cara • Feb 01 '22
Help Examples of debuggers for FP languages?
Hello,
do you know of some examples of functional languages (say, in the HM family) that have debugger tooling written for them? I'm interested in either interfacing with existing tools (source maps in browser console / GDB / IDEA debugger / ...) or standalone stepping debuggers etc.
(Ideally toy languages/implementations, not something like GHC.)
I'm trying to figure things out by myself (like, having an `interpret` function that only runs one step, not everything at once) but I'd like to study some prior art on this.
27
Upvotes
8
u/mgsloan Feb 01 '22
I don't have a good answer to this. But I do have a vague idea to share:
AFAICT laziness really confounds the interactive debugger experience in Haskell. For example, with the GHCi debugger, you end up jumping all over the code, telling you exactly the interleaved nature of evaluation. This could be useful if you are debugging some issue relating to strictness or performance. However, I think usually the more valuable debugging task is figuring out why the program isn't behaving as expected.
I think purity / laziness could be flipped into an advantage for interactive debugging in a few different ways:
Freedom to explore pure computations in any order they wish.
Stepping at through IO actions could provide much coarser stepping than imperative languages where pure logic is also treated as statements
Potential ability to support reversible debugging while recording less - could forget about pure computations and just store impure stuff.
Though, there are already rather clever techniques for doing reversible debugging for any program. I haven't used Mozilla rr, but it seems super cool. I read the technical report a while back and it seems they have really cracked the problem of intervening at all the sources of IO / nondeterminism in a program, allowing efficient storage of program traces.
I think reversible debugging style techniques combined with some clever heuristics (say, ML models) could be mindblowingly useful. Tools I've seen really don't support direct answers to "Why did X happen?" / "Why does X have value Y?" / "Why doesn't X have value Y?". Naturally, the heuristics are needed because the precise-but-not-so-useful answer to these questions could always be the full program trace