Paren-shapes and raco fmt

I'm trying to staple together existing tools so that I can take a datum such as

'(let ((a = 5)) (cond (b c) (d e)))

and generate this string:

{let {[a = 5]}
  (cond [b c]
        [d e])}

I think I can almost make this work by applying syntax wrappers with 'paren-shape syntax-properties, then using @sorawee 's fmt package. ... but I don't see a "front door" for fmt that accepts a syntax object, and I don't know how to write a syntax object to a string in a way that uses the paren-shape syntax properties (which would allow me to use the string-based front door). Either of these would solve the problem. Can anyone point me to either one of these?

syntax->string is an alternative that does accept a syntax object, but it also doesn't do the formatting that fmt does: it uses the syntax source locations to determine indentation and stuff, not good-style formatting rules

1 Like

Perfect! So if I funnel the result of syntax->string into fmt, I should be all good.

If I recall correctly, this won't work out if the box, but it should be possible with a minor change to fmt. I can take a look this weekend if you have not already solved it by then.