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.
@massung There is some URL that if you make a GET
request will return JSON about the package catalog.
tries to find the details…
@massung Little example I have from a few years ago: https://gist.github.com/greghendershott/b20effb9d9c48211e1c11d9486257918
Oh right it’s not JSON it’s a Racket #hash
literal because why not. :smile:
hmm. that gets all for sure. sadly it returns scheme code and not JSON
If you’re using it from Racket and want JSON you could just give that hash value to jsexpr->string
.
I think.
Or did you want to use it from Javascript or something else?
from JS
Maybe there’s a query param to make it return JSON, idk.
:slightly_smiling_face: ty for gist. shows there is an API that does exist at least
The source for the pkg mgr server is somewhere on github, maybe you can find it, or someone else here will know.
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
lol. Thanks @greg
@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
putting them together, looks like this works: <https://pkgd.racket-lang.org/pkgn/pkg/><pkg-name>.json
thanks for the help w/ that!
Someone like @jeapostrophe might know if that URL is supposed to be supported indefinitely or not.
(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.)
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->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"?
I like the way you define the helper function field->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
Use syntax-class attributes. I’ve added a comment with more details to your gist.
@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.]
The intent is that the primary communication is the calls to error-display-handler
The additional exception is because there has to be something.
Thanks for explaining the intent, that helps me feel more confident going with that approach.
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.
I don’t think it’s changed quite as much as thst
There’s still plenty of non-threaded replies
Ah, I see. Thank you both!
But I agree there’s been some shift
omg did you seriously reply inline here
i dont think its against the rules to reply inline is it ?
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
@jestarray certainly not against the rules. I mostly did it as a sort-of joke responding to @greg’s comments
This initial cut seems to be working in examples I’ve tried so far: https://github.com/greghendershott/racket-mode/commit/64c5c27623b38e1fb10cd9af56472dc93de1590f
I’m suspicious of special-casing Typed Racket here. DrRacket/various command line tools don’t have special cases for that.
Good point. I’ll reconsider that.
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.
But, the pregexp “Type Checker: ” aspect might not be necessary.
Maybe anything that follows this pattern, should work this way.
And, would not be broken if handled this way.
So I’ll think on that….
I don’t think that’s accurate about DrRacket
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.
(using check syntax)
But maybe you mean that’s just a final presentation detail, and it’s collecting them behind the scenes individually.
I don’t think it needs to match the msgs with srclocs for that box UI, is my point.
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.
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-.
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.
Don’t click the “check syntax” button.
just use the automatic background expansion
Oh you mean that’s only in bg mdoe?
Ah OK.
The bottom red text is based on bg expansion
I have that off by default because (at least in the past) it made things quite slow.
That isn’t my experience, and I literally never click the “check syntax” button.
OK with bg exp I see the behavior you describe. Thanks!
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).
Right, that’s what I mean
Thanks - just gave it a go and … well - it’s going to be tricky for me to debug racket
with it.
Cool :slightly_smiling_face:
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
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?
OK, that’s not it. But take a look at resample/interp
. It should do what you want with factor
equals 2.0
thanks! i will look into it
hopefully it wont change the pitch
going to play a voice over with slides switching based on audio ques
what do you guys recommend for crossplatform gui?