[racket] Want to pretty print transparent values in hashes with key/value pairs
This might help:
> (struct P (x) #:transparent)
> (pretty-print (hash 1 (P 2)))
(hash 1 (P 2))
> (pretty-write (hash 1 (P 2)))
#hash((1 . #(struct:P 2)))
On Wed, Nov 16, 2011 at 11:06 AM, J. Ian Johnson <ianj at ccs.neu.edu> wrote:
>> (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
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/users
>
--
sam th
samth at ccs.neu.edu