Here are some tracing macros if you're working in a REPL which odes not include these. I wouldn't be surprised if there was a more elegant way to define ‘trace-lambda’, or a better name for ‘multi’. It also might be useful to wrap ‘args’ in ‘multi’ with parenthesis so it can work with functions which take an arbitrary number of arguments, at the expense of a slightly more ugly syntax for an already rather ugly macro.
(define-syntax multi
(syntax-rules ()
((_ f args ...)
(begin (f args) ...))))
(define-syntax trace-lambda
(syntax-rules ()
((_ name (args ...) body ...)
(lambda (args ...)
(define name
(let ((indent " "))
(lambda (args ...)
(multi display indent "(" (quote name))
(multi display " " args) ...
(display ")\n")
(let ((old-indent indent)
(return
(begin
(set! indent (string-append indent ": "))
body ...)))
(set! indent old-indent)
(multi display indent return "\n")
return))))
(name args ...)))))
(define-syntax trace-define
(syntax-rules ()
((_ (name args ...) body ...)
(define name (trace-lambda name (args ...) body ...)))))
(define-syntax trace-let
(syntax-rules ()
((_ name ((keys values) ...) body ...)
((trace-lambda name (keys ...) body ...) values ...))))
(define-syntax trace
(syntax-rules ()
((_ exp) (let ((result exp)) (display exp) exp))))