
Does anyone have a better/stricter code formatter than pretty-format
? (@notjack @alexknauth maybe?)

For S-exp?

yes

What do you mean by “better/stricter”?

Something that writes like (let ([a b]
[c d])
(for ([i (in-naturals)]
[......])
(do)))

It can have a set of (maybe hardcoded, but good) conventions for newlines and brackets mostly

taylored to Racket

Is your input a syntax object or just an S-exp? Most printers that print paren shape correctly read extra info from syntax object.

Yes, I can have a syntax object. But I was hoping for a ‘standard’ formatter

That is, it may not preserve the initial code conventions.

FWIW,
#lang racket
(require racket/pretty)
(parameterize ([pretty-print-columns 30]
[pretty-print-current-style-table (pretty-print-extend-style-table
#f
'(for)
'(lambda))])
(pretty-print '(let ([a bbbbbbbb]
[c dddddddd])
(for ([i (in-naturals)]
[......])
(do)))))
produces
'(let ((a bbbbbbbb)
(c dddddddd))
(for ((i (in-naturals))
(......))
(do)))
Might be good enough for you?

Not really. It should format the let and for properly even with [pretty-print-columns 102]

And I was hoping for square brackets as per Racket’s convention

(The raco-format package merely tabifies)

Thanks for trying anyway @sorawee :slightly_smiling_face:

I thought I saw someone started a project to do a formatter for Racket, but it was in a very early stage when I saw it, so it’s probably not usable yet, and I can’t find it anymore

(I also have an unfinished formatter too welp)

That was for a quick-and-dirty refactor-like. In the end I’m using a mix of syntax->string
for the syntax parts that don’t need to change, and manual #\n
tags for the parts where I want to force a newline. It would still be nice to have a Racket reformatter though.

The quickscript is https://gist.github.com/Metaxal/cb9ba6d6a8214ef5f092fd82e83c32ff\|here for reference

Also tabify
ought to be extracted from text%
at some point.

That all sounds right to me.

Hello. I am trying to use this package <https://github.com/n3mo/data-science>
. It is already installed. How can I require
this package? Instruction not provided in the Github Readme page.

Assuming by “already installed” you mean raco pkg install
was successful, the info.rkt file in the github repo has this line: (define collection "data-science")
So, you should be able to just do (require data-science)
and it “just work”.

OK. That’s what I did. There is a bug in this package. I will report it!

Or possibly (require data-science/some-lib)
?

The error I am getting is Gtk initialization failed for display ":0"

I am running racket 8 inside docker container (using ubuntu 20.04)

I solved the problem!

The container must be run with the following environmental variables set … docker run -it --rm -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /home/phage/projects:/home/phage/projects --hostname rack8 --name rack8 rack8:base

So I think using the flag -e DISPLAY
may have solved the issue.

I noticed that others have this problem so I will post the solution to github. Thanks!

Where will you post?

I want to copy/link to from the Racket Wiki

Docker is so popular I feel this probably deserves a home in the documentation under ‘Deploying/Running racket’ but I’m not sure where to put it for now

@kyp0717 :arrow_up:

@spdegabrielle I have not posted it yet because I don’t know where. Please feel free to post it somewhere if you know where the solution should go.


I will try to post later on today. A little busy right now. Thanks for the suggestion.

I’d just dropped it in for now.

appreciate a check/edit when you have time.

Will do! Thanks!

Is there a helper macro for defining new for
loop syntaxes? Or - if not - some nice tips for handling the wealth of keyword arguments passable to it (e.g. #:when #:break, etc.)?

Take a look at for/fold/derived
and friends

thanks

that worked perfectly for me. Thanks again @sorawee

@spdegabrielle @kyp0717 There’s also the official racket/racket
images, which could be extended with some docs to explain how to install racket in docker yourself if you don’t want to use the official images. And I really should get around to transferring the github repo for those images into the racket
github org…

@massung If you feel up to the adventure of learning how to use rebellion’s reducers (https://docs.racket-lang.org/rebellion/Reducers.html\|https://docs.racket-lang.org/rebellion/Reducers.html) there’s make-reducer-based-for-comprehensions
, which can automatically make new for
and for*
forms from any reducer

I want a better formatter like what you’re describing very badly, and have experimented with making one on and off a few times

That issue also sounds like it’s a package that needs racket/gui
and not the common case?

I have some memory of running racket ‘headless’ coming up before but I’m probably misremembering

Wait @notjack are the official images different that yours? (We package Herbie with docker…)

@pavpanchekha they’re the same. I moved the jackfirth/racket
DockerHub images to racket/racket
with the help of samth

The jackfirth/racket-docker
GitHub repository is where the bash scripts and dockerfiles that actually build the images are. I’ve been meaning to transfer that repo to the racket GitHub organization but haven’t gotten around to it. But the location of the bash scripts has no effect on where the docker images get published. It gets confusing because DockerHub and GitHub both have “repositories” but they’re completely unrelated concepts.