a11ce
2020-12-9 10:34:14

@a11ce has joined the channel


a11ce
2020-12-9 10:38:43

Does racket or drracket provide any CLI form of the automatic indentation to use as a linter? If not, where is the source for it so I can reimplement it on its own?


laurent.orseau
2020-12-9 10:44:53

This is the method you are looking for: https://github.com/racket/gui/blob/81c7759987a99742d3138e96ca7b63a6b5d6920c/gui-lib/framework/private/racket.rkt#L819 Unfortunately, it’s tied to a text% gui widget.


a11ce
2020-12-9 10:47:18

thank you! is there a formal definition of correct racket indentation so i can go off that instead of the source?



laurent.orseau
2020-12-9 10:49:11

It’s a guide, not a formal definition though


laurent.orseau
2020-12-9 10:50:39

The most annoying part of designing yours will probably be preserving comments :wink:



amanrojjha01
2020-12-9 11:16:06

@amanrojjha01 has joined the channel


soegaard2
2020-12-9 13:00:12

Can elisp be called from the command line? If so, one line of attack is to look at the racket-mode code.

https://github.com/greghendershott/racket-mode/blob/master/racket-indent.el


laurent.orseau
2020-12-9 13:04:04

or this should be translated to racket!


soegaard2
2020-12-9 13:18:21

Also - indenting is hard. It is worthwhile to look at write ups for indenters for other languages.

Great blog post: http://journal.stuffwithstuff.com/2015/09/08/the-hardest-program-ive-ever-written/


soegaard2
2020-12-9 13:19:54

Also “A prettier printer” by Philip Wadler. https://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf


laurent.orseau
2020-12-9 13:40:56

Also possibly useful as a library for a racket pretty-printer: https://docs.racket-lang.org/pprint/index.html


yilin.wei10
2020-12-9 19:00:40

@soegaard2 Yes - you can call elisp from the command line with the --eval option


yilin.wei10
2020-12-9 19:02:52

It’s not so bad if you run it via emacsclient as well, otherwise it can be a little slow.


keith047
2020-12-9 19:17:28

@keith047 has joined the channel


samdphillips
2020-12-9 20:44:47

I’m playing with gstreamer making an audio player. Gstreamer runs worker threads to handle playback and it communicates with the application sending messages over custom FIFO. The fifo has ffi functions to retrieve messages with time out. I’m not sure how best to integrate this into a Racket gui application so that these messages can be tied to callbacks.


keith047
2020-12-9 22:13:56

What are people generally using as editors for racket? My guess is emacs & vim generally. I fired up DrRacket and had mixed feelings…it sure looked a lot like DrScheme from 20 years ago.


spdegabrielle
2020-12-9 22:14:03

The overscan package might have some examples but sadly I was never able to get it working. https://github.com/mwunsch/overscan/tree/master\|https://github.com/mwunsch/overscan/tree/master


keith047
2020-12-9 22:14:42

I saw there’s an LSP implementation, which intends to leverage DrRacket’s API, which seems like a good choice.


keith047
2020-12-9 22:15:37

But considering the module system, I find it strange that DrRacket doesn’t seem to have more support around projects/workspaces/multiple files/whatever. If I’m just ignorant, let me know!


spdegabrielle
2020-12-9 22:18:11

DrRacket and Emacs Racket Mode are the most popular and have the best Racket IDE functionality. That said racketeers use a wide variety of editors and IDE!’s; vim, VScode and others


spdegabrielle
2020-12-9 22:19:09

I believe the Magic Racket plugin for VSCode uses the LSP.


keith047
2020-12-9 22:20:19

Yep, I’ve been using that a little, and it’s not bad at all. I just spend so much time with vscode these days that it’s convenient to stay there with my keybindings and such.



soegaard2
2020-12-9 22:21:15

The philosophy is that to avoid configuration / project files - and instead put the information into racket files. This way the information can be used in different way - some information can be checked statically.

See the section on info files in the docs.

If you happen to have a “project” in a folder, you can use a plt-file to distribute it.


keith047
2020-12-9 22:21:47

Shows my ignorance, didn’t know that drracket had plugins.


keith047
2020-12-9 22:22:12

Probably there are plugins to solve some of my nits.


spdegabrielle
2020-12-9 22:22:56

It looks like DrScheme but a lot has changed


soegaard2
2020-12-9 22:23:06

@keith047 I think the number of VSCode users are growing. If you want a project, consider porting racket-mode to VSCode.

https://github.com/greghendershott/racket-mode


keith047
2020-12-9 22:23:13

I have little doubt about that :slightly_smiling_face:


keith047
2020-12-9 22:24:03

@soegaard2 could never grok elisp, even when I used emacs like 20+ years ago


spdegabrielle
2020-12-9 22:24:18

It also has scripts which are almost as powerful as plugins - the Script menu in the toolbar, quickscript in the documentation

https://github.com/racket/racket/wiki/DrRacket\|https://github.com/racket/racket/wiki/DrRacket


keith047
2020-12-9 22:24:20

Probably just bad memories




keith047
2020-12-9 22:26:41

I’m generally in favor of LSP, I feel like if I wanted to work on something that I’d go that route. But that would mean hacking on DrRacket probably, and I probably don’t have the need for any of this.


keith047
2020-12-9 22:27:45

(sadly, 99% of my open-source contributions are driven by the needs I have for work)


spdegabrielle
2020-12-9 22:28:24

I’m pretty sure you don’t need code Elisp to use Racket Mode


keith047
2020-12-9 22:28:48

I meant for the “port racket mode to vscode” part


keith047
2020-12-9 22:29:07

Maybe I didn’t know what you were talking about and said something dumb


spdegabrielle
2020-12-9 22:29:52

Sorry slack gets confusing and out-of-order


keith047
2020-12-9 22:30:27

But I think I’d be pretty happy with drracket with a) vim keybindings (I feel crippled without them) b) the file explorer thing c) readline-like behavior in the REPL. I’d be sorta surprised if all those things didn’t already exist.


keith047
2020-12-9 22:30:42

Yeah I know but I kinda despise the thread thing.



keith047
2020-12-9 22:32:16

That’s the funny part - I usually only use vim for quick edits and commit messages. But my fingers are stuck.


spdegabrielle
2020-12-9 22:32:21

(I can’t help with vim questions as I use DrRacket exclusively )


soegaard2
2020-12-9 22:33:01

I wasn’t thinking of a direct port, so it’s not necessary to be fluent in Elisp to get a gist of what happens. It’s easy to underestimate both the DrRacket and racket-mode repls. There is a lot going on under the hood. It’s not just send text back and forth from the editor to a running racket process.


yilin.wei10
2020-12-9 22:33:22

Let me know how you go about this! I had a similar problem a while back (without the GUI), and figured it would be easier to just write an interpreter in the C code which understood the “events”.


soegaard2
2020-12-9 22:34:17

Has anyone tried any of the lsp implementations for Racket with an editor like VScode or similar?


soegaard2
2020-12-9 22:34:34

Maybe that’s close enough.


yilin.wei10
2020-12-9 22:34:36

@keith047 Have you tried booting up Emacs with a vim emulator?


keith047
2020-12-9 22:34:49

:slightly_smiling_face:


sorawee
2020-12-9 22:35:11

Evil mode is really good


yilin.wei10
2020-12-9 22:36:03

It is; I do wish it was more maintainable though (maybe Emacs in general) I tried making a bugfix a whie back and couldn’t work out how on earth I caused a segfault.


keith047
2020-12-9 22:36:08

@soegaard2 I’ve used that magic racket extension in vscode. Are there other implementations of LSP for racket? I didn’t think to look that far.


sorawee
2020-12-9 22:37:03

The evil maintainers are also very busy. I submitted a patch for almost 6 months now and they haven’t merged it yet.


keith047
2020-12-9 22:38:01

The limitation of racket-langserver seems to be what APIs are provided by drracket. I think much is possible via drracket, but I would guess that it would need to have additional stuff exposed via API.


soegaard2
2020-12-9 22:38:55

@keith047 Sorry - it seems a lot of happened with Magic Racket since I looked at it last. I thought it was a simple syntax highlighter, but there is much more to it than that.


keith047
2020-12-9 22:38:59

I mean most of the things appear to exist in drracket - minus (AFAIK) good multifile support in drracket proper.


keith047
2020-12-9 22:40:33

But there are weirdisms like how (again, tell me if I’m wrong) I can’t autocomplete with local definitions in the definitions/REPL in drracket, but this works in the cli REPL.


keith047
2020-12-9 22:42:09

the magic racket repo asks for help mapping command- (or whatever per platform) so they use / instead - and I end up putting λ all over the place because that’s the default keybinding for “comment line” :stuck_out_tongue:


sorawee
2020-12-9 22:42:54

A DrRacket plugin DrComplete is very good for autocompletion.


sorawee
2020-12-9 22:43:25

sorawee
2020-12-9 22:45:25

DrRacket also supports autocompletion already, but only for definitions from other modules (not local definitions), IIRC.


keith047
2020-12-9 22:45:27

Sweet. I’ll have to check out plugins in general. I confess though, I just had good memories of using Scheme in school long ago, and I wanted to try out racket to see how it felt to me now. I’ve been doing the AoC stuff as a good way to practice. But it doesn’t really feel like how I’d write real racket code.


spdegabrielle
2020-12-9 22:45:28

There is also Fishy completion: autocompletion that is guaranteed to be in scope. https://github.com/sorawee/fishy-completion\|https://github.com/sorawee/fishy-completion. (Implemented as a script not a plugin)


sorawee
2020-12-9 22:46:11

Well, that’s a proof of concept. Use DrComplete instead. It’s far more mature.


badkins
2020-12-9 23:04:18

@keith047 I do most of my work in Emacs with racket-mode ; however, I almost always have an instance of DrRacket running that I use for experimenting - basically as a fancy REPL.


plragde
2020-12-9 23:13:20

Emacs still looks like Emacs from 20 years ago… or even earlier, really.


badkins
2020-12-9 23:16:13

Yes, a timeless classic :)


keith047
2020-12-9 23:16:44

@plragde you win.


badkins
2020-12-9 23:22:28

Emacs reminds me of this 20 year old car …


kellysmith12.21
2020-12-10 00:15:19

There appears to be a way to bind an id in such a way that it contains compile-time information that can be extracted with syntax-local-value and so that it can be treated as a normal runtime variable. How would I go about doing that? The procedure make-variable-like-transformer seems relevant but not quite the right thing.


samdphillips
2020-12-10 00:46:13

Thanks! I thought I had done my due diligence on prior work with gstreamer, and somehow missed this.


sorawee
2020-12-10 00:50:34

Like this?


sorawee
2020-12-10 00:51:09

#lang racket (begin-for-syntax (struct container (x) #:property prop:set!-transformer (λ (me stx) #'42))) (define-syntax foo (container 'secret)) (begin-for-syntax (println (container-x (syntax-local-value #'foo)))) ;; 'secret (println foo) ;; 42 (set! foo 3) ;; 42 (println foo) ;; 42


samth
2020-12-10 02:04:07

DrRacket completion is based on imported documented identifiers, whereas the racket repl uses the namespace directly (which isn’t available for a file that you’re editing). The racket-mode completion support is much better, as is the drcomplete plugin.


kellysmith12.21
2020-12-10 02:06:03

The container part only exists at compile time, correct?


greg
2020-12-10 02:16:39

I think that’s correct but @sorawee should confirm.


greg
2020-12-10 02:16:48

What you described sounded to me like a use for syntax properties. Maybe you already know about those and/or that wouldn’t be suitable for what you have in mind. But I wanted to mention just in case.


sorawee
2020-12-10 02:31:06

Yes, it only exists at compile-time.


kellysmith12.21
2020-12-10 04:13:31

My instinct was to use syntax properties, but I can’t figure out how to attach syntax properties to a binding created by define or let. I can use free identifier tables to map ids to various compile time data structures but, although that’s how things are done in most compilers, I have a feeling that it’s not the best way to do things in Racket.


notjack
2020-12-10 05:59:17

Syntax properties are for attaching compile-time information to terms, like the expression (+ 4 x). The approach with define-syntax and syntax-local-value is for attaching compile-time information to bindings.


notjack
2020-12-10 06:00:17

A good rule of thumb: if you want to stick information on a name and have all places that name is used able to get that information, you want define-syntax plus syntax-local-value. If you want to stick different information on different use sites of a name, you want syntax properties.


sorawee
2020-12-10 06:03:44

Also, another way to attach an information to binding is to use a hash on identifiers.



sorawee
2020-12-10 06:06:17

Oh, I didn’t see @kellysmith12.21 already mentioned that.


sorawee
2020-12-10 06:07:15

define-syntax + syntax-local-value is great when you have control over everything. But when you don’t have control over everything, the identifier table could work better.


sorawee
2020-12-10 06:07:31

Typed Racket uses identifier table, I think.


notjack
2020-12-10 06:09:16

wrapper modules also work