[racket] Want to pretty print transparent values in hashes with key/value pairs

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Wed Nov 16 14:06:21 EST 2011

> (struct A (a))
> (struct B (b) #:transparent)
> (pretty-print (make-hasheq (list (cons 'a (A 1)))))
'#hasheq((a . #<A>))
> (pretty-print (make-hasheq (list (cons 'b (B 1)))))
(hasheq 'b (B 1))

The alternating key/value pairs are confusing in large printouts in my program. How do I tweak pretty-printing for hashes so that the second printout looks like the following (I know it won't produce the same value when typed back in, but this is purely for presentation)?
'#hasheq((b . (B 1))

I'm trying to avoid writing my own pretty-printer.

Thanks,
-Ian


Posted on the users mailing list.