I have no clue how expensive it would be to implement, or how useful on real word projects, but one thing I've always been interested in is curry's mcc debugger: you type :debug expression in the REPL, which puts the expression in a queue and then this loop starts:
pop from queue
compute the value of the current expression
asks the user whether it's correct
if yes,continueloop
otherwise, clear the queue and put into the queue all the function calls that went into producing the value
When this process ends, because the queue is empty, it means that the error is in the last expression that was expanded.
For purely functional code it's pretty great, especially if recursive
fascinating!
Let me try and write an example
Example theoretical session:
eval = \expr ->
when expr is
Add es -> add es
Mul es -> mul es
Const c -> c
add = \es ->
when es is
[] -> 0
[ first, .. as rest ] -> eval first + add rest
mul = \es ->
when es is
[] -> 0 # The error is here
[ first, .. as rest ] -> eval first * mul rest
> :debug eval (Add [Const 3, Mul [Const 3, Const 4]])
1. eval (Add [Const 3, Mul [Const 3, Const 4]]) --> 3
Which one is wrong? [n for none]
> 1
1. add [Const 3, Mul [Const 3, Const 4]] --> 3
Which one is wrong? [n for none]
> 1
1. eval (Const 3) --> 3
2. eval (Mul [Const 3, Const 4]) --> 0
Which one is wrong? [n for none]
> 2
1. mul [Const 3, Const 4] --> 0
Which one is wrong? [n for none]
> 1
1. eval (Const 3) --> 3
2. mul [Const 4] --> 0
Which one is wrong? [n for none]
> 2
1. eval (Const 4) --> 4
2. mul [] --> 0
Which one is wrong? [n for none]
> 2
The error is in the `mul` function
My main doubts are:
By the way, I think you could give chatGPT-like models capable debugging powers with a tool like this.
Last updated: Jun 16 2026 at 16:19 UTC