
@d.zivertas has joined the channel

Is there a collection of macro exercises for practice/skills building ?

Racket Summer Schools have several macro exercises.


Any suggestions on how to get started with building api websites with Racket? I am a beginner to Racket, so don’t have much experience with it. I did a search here and Koyo came up. I am going to look through the video, but it seems like a complete framework with a lot of functionality. It is a little overwhelming for a beginner to Racket and someone who has used more basic frameworks like Flask (not Django, not Ruby-onRails). Would appreciate any comments on where I should start. Also, what do you think of Jesse Alama’s book. Is that good? I tried to click to get the sample chapter, but the link does not work.

Thanks for your help.


Start with listit
which has the most basic version. In listit2
a few things have been addded. In listit3
more things are added. In listit4
even more things.
And then the actual code in production: https://github.com/soegaard/racket-stories

The repo is called “web tutorial”, but the tutorial unfortunately didn’t spontaneous materialize.

That said, Koyo is a much more professional web-framework. I would love to see some tutorials for it.

Thank you very much @soegaard2. Will look at these links. Racket is lucky to have a helpful member like you.

If you clone the repo, you ought to start the first example with: cd listit
racket server.rkt

@curiouslearn :wave: can you let me know where the link is?

I have some specifically for writing macros that use continuations https://gist.github.com/jackfirth/027411d567385dadb3202bee75a847b4\|https://gist.github.com/jackfirth/027411d567385dadb3202bee75a847b4

Is <https://docs.racket-lang.org/peg/index.html?q=peg|this PEG library> the one described in the paper, “Macros for Domain-Specific Languages”?

No, I don’t think so

I think this is the one: https://github.com/michaelballantyne/racket-peg-ee

I’ll pass it on

Hi Jesse,

The link is here: https://gumroad.com/l/serverracket when you go to the Sample Chapter section.

Hi, I am working through “More: Systems Programming with Racket” (https://docs.racket-lang.org/more/). In the examples there, the authors use regex to parse the http request. I want to see what the request looks like to understand what the regex is doing. As the authors state on that site, they are using the regex directly on input stream. How can I can convert the whole input stream to a string and print it out so that I can see the contents of that request? Thank you.

I think you want port->string

Thanks! Yes, that does it. That causes the regex
to fail. I suppose it is because the input port is now empty. Will check how to deal with it. Passing the string to regex does not work.

The way that code uses the input port is stateful, so replicating it on a string will be tricky

Eventually I’d like something more stable and less powerful to rely on, so I made a bug https://github.com/jackfirth/resyntax/issues/19\|https://github.com/jackfirth/resyntax/issues/19 @ryanc your thoughts on this would be greatly appreciated

Thank you @samth. Another thing I don’t understand is why removing the regex-match
line in the code below, causes the requests to fail. It appears that the match not used for anything when responding.
(define (handle in out)
; Discard the request header (up to blank line):
(regexp-match #rx"(\r\n\|^)\r\n" in)
; Send reply:
(display "HTTP/1.0 200 Okay\r\n" out)
(display "Server: k\r\nContent-Type: text/html\r\n\r\n" out)
(display "<html><body>Hello, world!</body></html>" out))

The regexp-match
reads the rest of the request. If the client waits to finish writing the request, before trying to read the response, that will never happen?

I understand you want to see the request. Instead of trying to remove the regexp-match
expressions from the example, would it help if you simply wrap each of them in println
?

e.g. change (regexp-match #rx"(\r\n\|^)\r\n" in)
to (println (regexp-match #rx"(\r\n\|^)\r\n" in))

@curiouslearn

ah, thanks! Silly mistake on my part