laurent.orseau
2021-7-30 07:17:08

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


sorawee
2021-7-30 07:17:43

For S-exp?


laurent.orseau
2021-7-30 07:18:28

yes


sorawee
2021-7-30 07:18:53

What do you mean by “better/stricter”?


laurent.orseau
2021-7-30 07:19:52

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


laurent.orseau
2021-7-30 07:20:25

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


laurent.orseau
2021-7-30 07:20:37

taylored to Racket


sorawee
2021-7-30 07:24:05

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


laurent.orseau
2021-7-30 07:25:13

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


laurent.orseau
2021-7-30 07:25:41

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


sorawee
2021-7-30 07:29:34

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?


laurent.orseau
2021-7-30 07:30:56

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


laurent.orseau
2021-7-30 07:31:10

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


laurent.orseau
2021-7-30 07:36:02

(The raco-format package merely tabifies)


laurent.orseau
2021-7-30 07:40:14

Thanks for trying anyway @sorawee :slightly_smiling_face:


sorawee
2021-7-30 07:43:51

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


sorawee
2021-7-30 07:44:21

(I also have an unfinished formatter too welp)


laurent.orseau
2021-7-30 09:54:44

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.


laurent.orseau
2021-7-30 11:47:04

laurent.orseau
2021-7-30 12:03:48

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


mflatt
2021-7-30 13:57:29

That all sounds right to me.


kyp0717
2021-7-30 15:02:24

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.


massung
2021-7-30 15:07:03

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”.


kyp0717
2021-7-30 15:09:26

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


ben.knoble
2021-7-30 15:25:02

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


kyp0717
2021-7-30 15:27:54

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


kyp0717
2021-7-30 15:30:37

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


kyp0717
2021-7-30 15:33:51

I solved the problem!


kyp0717
2021-7-30 15:35:07

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


kyp0717
2021-7-30 15:35:49

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


kyp0717
2021-7-30 15:36:30

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


spdegabrielle
2021-7-30 16:02:46

Where will you post?


spdegabrielle
2021-7-30 16:03:03

I want to copy/link to from the Racket Wiki


spdegabrielle
2021-7-30 16:05:56

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


spdegabrielle
2021-7-30 16:06:24

@kyp0717 :arrow_up:


kyp0717
2021-7-30 16:07:37

@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.


spdegabrielle
2021-7-30 16:08:37

kyp0717
2021-7-30 16:09:31

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


spdegabrielle
2021-7-30 16:11:00

I’d just dropped it in for now.


spdegabrielle
2021-7-30 16:11:16

appreciate a check/edit when you have time.


kyp0717
2021-7-30 16:13:59

Will do! Thanks!


massung
2021-7-30 17:24:42

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.)?


sorawee
2021-7-30 17:25:55

Take a look at for/fold/derived and friends


massung
2021-7-30 17:26:45

thanks


massung
2021-7-30 17:34:15

that worked perfectly for me. Thanks again @sorawee


notjack
2021-7-30 23:08:58

@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…


notjack
2021-7-30 23:13:09

@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


notjack
2021-7-30 23:17:05

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


samdphillips
2021-7-30 23:18:40

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


spdegabrielle
2021-7-31 00:17:38

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


pavpanchekha
2021-7-31 00:44:07

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


notjack
2021-7-31 03:11:42

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


notjack
2021-7-31 03:14:40

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.