[racket-users] Re: Pretty Printing for ASTs represented as structs

2020-08-17 Thread Jeremy Siek
Thanks for the tip! I found the following to work pretty well :) #lang racket (require racket/match) (require racket/struct) (struct Var (name) #:methods gen:custom-write [(define (write-proc ast port mode) (match ast [(Var x) (write x port)]))]) (struct Num (value)

[racket-users] Re: Pretty Printing for ASTs represented as structs

2020-08-16 Thread jackh...@gmail.com
I recommend using make-constructor-style-printer , which automates a lot of the fiddly indentation-handling you'd have to do otherwise. On Sunday, August 16, 2020 at