Stream: ideas

Topic: interactive debugging


view this post on Zulip Leonardo Taglialegne (Mar 25 2023 at 12:39):

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, continue loop
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

view this post on Zulip Anton (Mar 25 2023 at 12:41):

fascinating!

view this post on Zulip Leonardo Taglialegne (Mar 25 2023 at 12:45):

Let me try and write an example

view this post on Zulip Leonardo Taglialegne (Mar 25 2023 at 12:49):

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

view this post on Zulip Leonardo Taglialegne (Mar 25 2023 at 12:50):

My main doubts are:

  1. how much does this cost to implement
  2. how useful is this outside "classroom" contexts
  3. how do you deal with expressions that are 10 lines long

view this post on Zulip Anton (Mar 25 2023 at 14:04):

  1. It's a more minimalist and focused version of "step over, step into" IDE debuggers. It's hard to know if it would be better but once you have "step over" and "step into" support this doesn't seem like much additional work to try out.
  2. As a "final product" I suppose you would put this in a nice GUI and have a Large Language Model format the expressions in a digestible way.

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