
hi, I want to know how to change the output rules of pretty-print
. I’ve read the documentation for pretty-print
, but I couldn’t figure out how to use the procedures at all. input: (define input
'(module (import "" "add" (func $add ...))
(import "" "sub" (func $sub ...))
(import "" "mul" (func $mul ...))
...))
actual: (pretty-print input)
> '(module (import "" "add" (func $add ...))
(import "" "sub" (func $sub ...))
(import "" "mul" (func $mul ...))
...)
expected: (pretty-print input)
> '(module
(import "" "add" (func $add ...))
(import "" "sub" (func $sub ...))
(import "" "mul" (func $mul ...))
...)

@mildc055ee Something like: #lang racket
(require racket/pretty)
(define input
'(module (import "" "add" (func $add ...))
(import "" "sub" (func $sub ...))
(import "" "mul" (func $mul ...))
...))
(define my-style
(pretty-print-extend-style-table (pretty-print-current-style-table)
'(module)
'(begin)))
(pretty-print-current-style-table my-style)
(pretty-print-columns 80)
(pretty-print input)

Here we make your custom module
form print like a normal Racket begin
form.

Advertisement time: with https://github.com/sorawee/fmt, you can also pretty print the above code with more extensibility and prettiness:
#lang racket
(require fmt)
(define input
'(module (import "" "add" (func $add ...))
(import "" "sub" (func $sub ...))
(import "" "mul" (func $mul ...))
(let ([x 1])
(set! x (add1 x))
(set! x (add1 x)))))
(define (my-format name)
(case name
[("module") (format-node-uniform-body 0)]
[("import") format-node-#%app]
[else (standard-format name)]))
(pretty-print* input #:format my-format)
outputs:
'(module
(import "" "add" (func $add ...))
(import "" "sub" (func $sub ...))
(import "" "mul" (func $mul ...))
(let ([x 1])
(set! x (add1 x))
(set! x (add1 x))))
whereas with the racket/pretty
library, it outputs:
'(module
(import "" "add" (func $add ...))
(import "" "sub" (func $sub ...))
(import "" "mul" (func $mul ...))
(let ((x 1)) (set! x (add1 x)) (set! x (add1 x))))

@mflatt On Linux, package maintainers have to manually add .LOCKpkgs.rktd
in order for Drracket to work. Is this a recommended approach? https://github.com/racket/racket/issues/3851#issuecomment-927457199

Great initiative!