massung
2020-2-10 14:22:54

Does the Raco Package Manager have any kind of REST API that I can use to query a package (by name) from my web server and get things like:

• Current Version CRC • Whether the build is succeeding or not • Dependencies (and possibly recursively get their data?) • Author, last update UTC timestamp, etc.


greg
2020-2-10 14:45:11

@massung There is some URL that if you make a GET request will return JSON about the package catalog.


greg
2020-2-10 14:45:21

tries to find the details…


greg
2020-2-10 14:46:49

@massung Little example I have from a few years ago: https://gist.github.com/greghendershott/b20effb9d9c48211e1c11d9486257918


greg
2020-2-10 14:48:30

Oh right it’s not JSON it’s a Racket #hash literal because why not. :smile:


massung
2020-2-10 14:48:31

hmm. that gets all for sure. sadly it returns scheme code and not JSON


greg
2020-2-10 14:50:21

If you’re using it from Racket and want JSON you could just give that hash value to jsexpr->string.


greg
2020-2-10 14:50:31

I think.


greg
2020-2-10 14:50:43

Or did you want to use it from Javascript or something else?


massung
2020-2-10 14:50:48

from JS


greg
2020-2-10 14:51:29

Maybe there’s a query param to make it return JSON, idk.


massung
2020-2-10 14:52:22

:slightly_smiling_face: ty for gist. shows there is an API that does exist at least


greg
2020-2-10 14:52:42

The source for the pkg mgr server is somewhere on github, maybe you can find it, or someone else here will know.


greg
2020-2-10 14:58:29

OK I had to go find it. :slightly_smiling_face: Looks like no JSON option: https://github.com/racket/pkg-index/blob/master/basic/main.rkt#L51-L54


massung
2020-2-10 14:59:53

lol. Thanks @greg


greg
2020-2-10 15:11:24

@massung I don’t know if this URL is official or not — I piece it together by looking at the JS page source for the pkg web site — but this seems to work: https://pkgd.racket-lang.org/pkgn/pkgs-all.json


massung
2020-2-10 15:12:11

putting them together, looks like this works: <https://pkgd.racket-lang.org/pkgn/pkg/>&lt;pkg-name&gt;.json


massung
2020-2-10 15:12:32

thanks for the help w/ that!


greg
2020-2-10 15:12:39

Someone like @jeapostrophe might know if that URL is supposed to be supported indefinitely or not.


greg
2020-2-10 15:13:34

(IIRC pieces of this are dynamic, and pieces are hosted on S3, and in the past the subdomains and other things had changed a bit.)


me1150
2020-2-10 16:37:12

Does anyone have pointers to resources (either docs or code examples) for writing more modular macro code involving syntax-parse? I find myself wanting to factor out functionality from a single monolithic syntax-parse body, and I’m not quite sure what’s the “right” way to do it.

Here’s a slightly artificial but concrete example: https://gist.github.com/anishathalye/0fca51025a70cc9af5a86e4fe796290c

So I’ve got modularity now, at the expense of parsing the same thing twice (the field is parsed in the parse-fields macro, and then again in the field-&gt;struct macro). How can this duplication be avoided? Is there a way to “pass the parsed object into another function”, so that the function may use it in a template without parsing syntax again"?


soegaard2
2020-2-10 16:53:06

I like the way you define the helper function field-&gt;struct. Parsing the field twice is a small price to pay,

A style variation using with-syntax and stx-map: https://gist.github.com/anishathalye/0fca51025a70cc9af5a86e4fe796290c#gistcomment-3172267


ryanc
2020-2-10 17:18:06

Use syntax-class attributes. I’ve added a comment with more details to your gist.


greg
2020-2-10 17:58:42

@samth I want to better support the case where Typed Racket reports multiple errors — which is a wonderful TR feature. The status quo seems a little odd. exn:fail:syntax supports a single message, and multiple srcloc s — but the intent is those are “least to most specific”. How TR seems to use this is, supply an “N errors summary” message and the srclocs but not the messages for the individual errors. (It does seem to run each through error-display-handler. And DrRacket seems to collect those into one single message.)

Whereas I’d like to display at each location the error message for that location.

It seems like in the future it could make sense to have something like exn;fail:syntaxes plural (or some better name), which provides a list of (cons message srcloc) for each error?

[Meanwhile I can do something like parameterize error-display-handler to get each message, see if it starts with “Type checker”, and store it. And later try to match those up with srclocs. And it will probably work OK. It’s just kind of a kludge.]


samth
2020-2-10 18:00:29

The intent is that the primary communication is the calls to error-display-handler


samth
2020-2-10 18:00:47

The additional exception is because there has to be something.


greg
2020-2-10 18:02:11

Thanks for explaining the intent, that helps me feel more confident going with that approach.


greg
2020-2-10 18:06:41

I wanted to acknowledge something I just realized. Before anyone feels like they need to take me aside and point it out. :slightly_smiling_face: I’ve been away from Racket Slack for some months. When I was here before, it was much “flatter” — replies inline in the channel. I’m realizing the etiquette or convention changed while I was away — try to do replies in a thread. So… sorry for not doing that recently, and I will try to remember to do that going forward.


samth
2020-2-10 18:07:29

I don’t think it’s changed quite as much as thst


samth
2020-2-10 18:07:43

There’s still plenty of non-threaded replies


me1150
2020-2-10 18:07:53

Ah, I see. Thank you both!


samth
2020-2-10 18:07:54

But I agree there’s been some shift


greg
2020-2-10 18:08:27

omg did you seriously reply inline here


jestarray
2020-2-10 18:12:42

i dont think its against the rules to reply inline is it ?


jestarray
2020-2-10 18:17:26

https://blog.discourse.org/2018/11/free-hosting-for-open-source-v2/ , racket seems to qualify for free discourse hosting being a FOSS project after all. not sure if people would want to migrate everything over from google groups but discourse loads significantly faster and is more user friendly


samth
2020-2-10 18:18:20

@jestarray certainly not against the rules. I mostly did it as a sort-of joke responding to @greg’s comments


greg
2020-2-10 18:45:57

This initial cut seems to be working in examples I’ve tried so far: https://github.com/greghendershott/racket-mode/commit/64c5c27623b38e1fb10cd9af56472dc93de1590f


samth
2020-2-10 18:48:18

I’m suspicious of special-casing Typed Racket here. DrRacket/various command line tools don’t have special cases for that.


greg
2020-2-10 18:49:23

Good point. I’ll reconsider that.


greg
2020-2-10 18:50:13

DrRacket seems to collect all the messages and present them as one string in one text box. Whereas I’m trying to make (msg srcloc) tuples, and show them one by one in situ.


greg
2020-2-10 18:50:31

But, the pregexp “Type Checker: ” aspect might not be necessary.


greg
2020-2-10 18:50:53

Maybe anything that follows this pattern, should work this way.


greg
2020-2-10 18:51:24

And, would not be broken if handled this way.


greg
2020-2-10 18:51:46

So I’ll think on that….


samth
2020-2-10 18:52:21

I don’t think that’s accurate about DrRacket


greg
2020-2-10 18:53:11

Well I just tried it an hour ago to double-check, and got a single error message textbox with all 3 (in my example) messages appended as one.


greg
2020-2-10 18:53:21

(using check syntax)


greg
2020-2-10 18:54:10

But maybe you mean that’s just a final presentation detail, and it’s collecting them behind the scenes individually.


greg
2020-2-10 18:54:26

I don’t think it needs to match the msgs with srclocs for that box UI, is my point.


samth
2020-2-10 18:55:41

When I try the following: #lang typed/racket (+ 1 "foo") ("foo") and then see the results in online check syntax, I can press C-. and switch between the errors and it changes the message shown in the bottom line and also changes what is highlighted.


greg
2020-2-10 19:00:50

I wasn’t aware of C-. and I see that does work for me, too. So it knows the srclocs. But I don’t see it display individual messages, below. I have one box at the top “Check Syntax Error Message”, and nothing seems to change there as I use C-.


greg
2020-2-10 19:01:55

So I’m still not sure it’s really doing exactly what I want to do. But I accept your point that (a) I probably shouldn’t special case typed racket like I am now, and (b) I should probably look at some more DrR code for edification.


samth
2020-2-10 19:02:50

Don’t click the “check syntax” button.


samth
2020-2-10 19:02:58

just use the automatic background expansion


greg
2020-2-10 19:03:02

Oh you mean that’s only in bg mdoe?


greg
2020-2-10 19:03:07

Ah OK.


samth
2020-2-10 19:03:23

The bottom red text is based on bg expansion


greg
2020-2-10 19:03:25

I have that off by default because (at least in the past) it made things quite slow.


samth
2020-2-10 19:04:15

That isn’t my experience, and I literally never click the “check syntax” button.


greg
2020-2-10 19:04:42

OK with bg exp I see the behavior you describe. Thanks!



greg
2020-2-10 19:19:31

So, not to belabor this, but: When a #lang racket program has some expansion error, it simply raises exn:fail:syntax. There is no business about calling error-display-handler before raising the exception. It might get called later if something isn’t catching the exn and it bubbles up to the default handler. But in my case it won’t (I want to catch the errors and re-present them to the front end.)

Now, when something like TR can raise multiple errors (which again is great!), what TR does seems like a reasonable “protocol”, even if not exactly documented explicitly. How else could it work? exn:fail:syntax singular isn’t really intended to handle it. So, maybe I should handle that pattern, without labeling it as TR specific, even though TR is the first (and so far only) example I know. If that’s what you mean, I agree (and even went ahead and did that, not yet committed).


samth
2020-2-10 19:20:04

Right, that’s what I mean


pocmatos
2020-2-10 19:20:22

Thanks - just gave it a go and … well - it’s going to be tricky for me to debug racket with it.


greg
2020-2-10 19:20:31

Cool :slightly_smiling_face:


jestarray
2020-2-11 00:40:51

is there a way to make rsound play audio at 2x speed ? https://docs.racket-lang.org/rsound/index.html , can’t seem to find where to control playback speed


sorawee
2020-2-11 02:16:26

I’ve never used rsound, but https://docs.racket-lang.org/rsound/index.html#%28def._%28%28lib._rsound%2Fmain..rkt%29._default-sample-rate%29%29 looks like it can be used to control how fast to play?


sorawee
2020-2-11 02:38:46

OK, that’s not it. But take a look at resample/interp. It should do what you want with factor equals 2.0


jestarray
2020-2-11 05:10:29

thanks! i will look into it


jestarray
2020-2-11 05:10:34

hopefully it wont change the pitch


jestarray
2020-2-11 05:10:57

going to play a voice over with slides switching based on audio ques


jestarray
2020-2-11 07:03:12

what do you guys recommend for crossplatform gui?