spdegabrielle
2021-3-11 10:03:01

Racket Stories

Hi All,

Racket Stories has close to 400 links to Racket related stuff.

Help me get to 500.

Submit blog posts, libraries, one off Racket hacks, …

New or old doesn’t matter - if it is interesting to you, it’s probably interesting to others as well.

Don’t forget to vote on the stories.

/soegaard


sschwarzer
2021-3-11 13:46:39

Is there a way (command line tool?) to find out about unused requires and/or provides of identifiers that aren’t anymore in the module?


sschwarzer
2021-3-11 13:50:15

By the way, I didn’t even know about define-syntax-parse-rule, even the whole https://docs.racket-lang.org/syntax/index.html document(s). The documentation on Racket macros is kind of overwhelming, so much that it’s sometimes difficult to know which APIs to use (especially as a beginner in macros). But I guess it’ll become clearer when I’m more used to macros and writing a few.


soegaard2
2021-3-11 14:28:12

DrRacket and racket-mode can detect them - but I don’t know of a command line tool.


greg
2021-3-11 14:28:44

I thought this was also exposed as a raco command.


soegaard2
2021-3-11 14:29:03

Maybe it is?


greg
2021-3-11 14:29:23

raco check-requires


greg
2021-3-11 14:29:31

I had to look it up.


greg
2021-3-11 14:30:35

It doesn’t check “unused provides”, though. To do that you’d need some inter-file database. Well, for provides at the top file module level.


greg
2021-3-11 14:31:17

(Weird timing, I’ve been experimenting with making such a database. But that’s WIP.)


greg
2021-3-11 14:32:24

@sschwarzer ^


laurent.orseau
2021-3-11 18:01:02

It’s working \o/

#lang racket (require define2) (define (foo bar [baz 'b] #:fizz fizz #:buzz [buzz #t]) #t) ; Examples of syntax errors: (foo) #;(foo 'a 'b 'c #:fizz 'f) #;(foo 'a) #;(foo 'a #:fizz 'f #:beurre 'b) Compile without running: $ raco make define2-example.rkt And get nice syntax errors at compile time: foo: missing mandatory positional arguments; header: (foo bar (baz) #:fizz (#:buzz)) at: (foo) in: (foo) foo: too many positional arguments; header: (foo bar (baz) #:fizz (#:buzz)) at: (foo 'a 'b 'c #:fizz 'f) in: (foo 'a 'b 'c #:fizz 'f) foo: missing keywords; header: (foo bar (baz) #:fizz (#:buzz)) at: (foo 'a) in: (foo 'a) foo: unknown keyword; header: (foo bar (baz) #:fizz (#:buzz)) at: #:beurre in: (foo 'a #:fizz 'f #:beurre 'b) @notjack


samdphillips
2021-3-11 18:19:36

Yeah ideally the guide should be an intro, and it should link out to the appropriate parts of the references.


laurent.orseau
2021-3-11 18:31:24

It’s even nicer in DrRacket of course (again at compile time, no need to run the program)


sorawee
2021-3-11 18:35:19

Does it support the curry notation?


laurent.orseau
2021-3-11 18:36:08

ah, not yet, good point. It supports rest arguments though


laurent.orseau
2021-3-11 18:37:03

hm actually, I need to test (later), but it should support the curry notation to some extent (at least the first level)


laurent.orseau
2021-3-11 19:27:03

Code is here:https://github.com/Metaxal/define2/blob/syntax-errors/define.rkt#L59 All comments welcome! (note that for now it’s in the syntax-errors branch)


laurent.orseau
2021-3-11 19:42:09

Yes, it works also in the curried version, but syntax errors are reported only for the first level


notjack
2021-3-11 20:09:43

this is awesome!!


notjack
2021-3-11 20:25:30

The docs for my resyntax package haven’t been updated in a day or two, is the build server taking longer than usual again?


greg
2021-3-11 20:38:35

This is really nice! The only thing similar to this I’ve seen is messages to the “optimizer” logger topic — but you have to have a logger window open to notice, and, they’re effectively warnings not errors. So this seems much better!


greg
2021-3-11 20:39:22

Dumb question (I may have missed previous discussion): Why doesn’t Racket’s define already do this?


notjack
2021-3-11 20:48:42

backward compatibility and increased code size, probably


notjack
2021-3-11 20:49:12

(it’s backwards incompatible because it causes modules with dead code to stop compiling if the dead code calls functions incorrectly)


sorawee
2021-3-11 21:15:53

I just uploaded https://github.com/sorawee/mixfix, a library that supports mixfix notation, to the package index. Meanwhile, here’s a locally rendered documentation. Any feedback is welcome!


ben.knoble
2021-3-11 21:16:28

Had to go see the README to get it, but this is awesome! Destructuring let/lambda/define next, anyone?


jaz
2021-3-11 21:27:39

@ben.knoble have you seen generic-bind?


ben.knoble
2021-3-11 21:27:59

No, maybe I will be interested… it’s the one thing I miss from Clojure, honestly.



ben.knoble
2021-3-11 21:30:01

That’s cool; it’s unfortunate that the syntax is a bit different. In Clojure, the syntax for the destructuring looks exactly like the literal syntax.


notjack
2021-3-11 21:49:29

It can’t look exactly like the normal syntax in racket, because if it did then (define (foo x) 4) would be ambiguous (does it mean define a function foo with a parameter x that returns 4, or match 4 against the pattern (foo x)?)


ben.knoble
2021-3-11 21:50:09

Yeah, I do understand that.


laurent.orseau
2021-3-11 22:11:01

This is really cool!


laurent.orseau
2021-3-11 22:23:31

Anyone knows how to make #:fail-when in syntax-parse avoid having both in and at when they are the same?


kellysmith12.21
2021-3-12 03:26:42

In the Typed Racket REPL, the type of an expression is printed along with the value. Is that done by reifying the type as a runtime value for printing, or is a string representation just constructed statically?


notjack
2021-3-12 03:29:25

I would guess the latter, because of phase crossing



notjack
2021-3-12 04:16:33

When I eval a module, it doesn’t print out the values in the module body. Why is that? What do I need to do to get it to print the values?


sorawee
2021-3-12 04:25:25

You need to require it, right?


sorawee
2021-3-12 04:26:22

There are terms like “instantiate”, “visit”, etc. I don’t recall which is which, but require will do those things.


notjack
2021-3-12 04:27:06

Oh duh. Ugh. So given this: (eval #'(module foo racket/base (or 1 2 3))) I then need to require 'foo


notjack
2021-3-12 04:54:33

Extremely cool (to me) resyntax thing: the testing framework I wrote for testing refactoring changes now automatically checks that the stdout and stderr of refactored programs doesn’t change


sorawee
2021-3-12 05:31:43

It would be really great if the build server has a status page that displays its schedule or something indicating that it’s alive.

If the server is just being slow, that’s totally fine for me. But if it errors, that should be reported. The problem is that I don’t know how to distinguish the two.

(And I feel bad every time I ping Matthew and Sam re: “is the server down?” and it turns out that it’s just being slow)