Pyffi - Use Python from Racket

I think you would either need to have a different version of run that produced the full printout, or a different version of make-log-based-evaluator that did the printing a logging time.

The function run is just one of many functions exported by pyffi, so I have looked at
the other option. Given an evaluator returned from make-log-based-evaluator the function wrap
below will do the printing at evaluation time. Combined with make-log-based-evaluator I can record and replay the evaluations.

However, the examples form doesn't know, that the values it receives have been pretty printed already.

The wrap function was tricky. The examples form calls the evaluator multiple times for each example. Besides the value(s) of each example expression, it also needs to know about any activity on output and debug ports. This is done by sending "evaluator messages", but evaluator-message? is not exported from racket/sandbox.

@(require racket/match rackunit)
@(require/expose racket/sandbox (evaluator-message?))
@(define (wrap ev)
   (lambda (x)
     (call-with-values
      (λ ()
        (if (evaluator-message? x)
            (ev x)
            (match x
              ; these non-expressions are used in the manual
              [(cons (or 'require 'define 'import) _)
               (ev x)]
              [else
               (ev `(with-output-to-string (λ () (print ,x))))])))
      (λ vs (apply values vs)))))

Example output:

How do I get examples to format these pretty printed values correctly?