I spent a while implementing a pretty-printer in elisp, only to realise that ielm already has a fine pretty-printer. Turns out that pp-to-string is built-in to Emacs!
(I missed this initially because of the short name: I only found cl-prettyprint.)
Wilfred Hughes