
hello. I have question - exists simple way for compile scheme into JS (f.e. as clojurescript)



This very question came up today at https://stackoverflow.com/questions/60484316/installing-racket-packages-without-installing-dr-racket

I was gonna say, do raco pkg install --binary-lib sql
, but it still doesn’t work

Ah, it needs to be raco pkg install --catalog <https://pkg-build.racket-lang.org/server/built/catalog/> --binary-lib sql

So, I managed to get this working, as detailed in my answer to the StackOverflow post. However, it’s not perfect. I need to separately raco pkg install rackunit-lib db-lib
because if I don’t, I will get an error like:
package-catalog-lookup: error from server
URL: <https://pkg-build.racket-lang.org/server/built/catalog/pkg/db-lib?version=7.6>
status code: 403
And it is the case that https://pkg-build.racket-lang.org/server/built/catalog/pkg/db-lib?version=7.6 is an invalid link, while https://pkg-build.racket-lang.org/server/built/catalog/pkg/sql?version=7.6 is not. Does anyone know what’s going on?

And it’s been like this for 7.5, too

@wwall @sorawee I can’t recommend using Whalesong anymore. It only runs on very old versions of DrRacket and it hasn’t been updated for years.
The simplest to use project in the Racket world is racketscript
.
An alternative is Urlang
which isn’t full Racket, but rather JS+Scheme-like-features.
An example of a Space Invaders game in Urlang. https://github.com/soegaard/urlang/blob/master/urlang-examples/space-invaders/space-invaders.rkt#L102

Thanks

Packages in the v7.6 main distribution are in the catalog https://download.racket-lang.org/releases/7.6/catalog/ in built form, and the pkg-build server doesn’t currently try to build them or recatalog them.

Hmm. Is it considered a bug then? It makes installation of packages in minimal Racket really difficult.

The original intent is that you’d use both catalogs: the distribution one first, and then the pkg-build one.

That doesn’t sound ergonomic. It means I need to read info.rkt
to see what are dependencies (and potentially need to find transitive dependencies), and find which ones are in the main distribution.

Then go fix it.

I’m so glad this is being done!

Hi! What’s the cleanest way to overload a struct constructor? I’m using Typed Racket and I want to make an explicitly dependent function type for a struct constructor but I’m not sure what the best approach is for this case

An idea (but I am no Typed Racket expert): Use a submodule to define your struct and your alternative constructor. Then use rename-out to export your custom constructor instead of the default one.

That’s the approach I’m considering at the moment but I was wondering if there is a more ergonomic approach. I only want to make the auto-generated constructor dependently typed without modifying its implementation.
I’ll need to do this for a whole bunch of structs so that’s why I’m wondering if there is a better approach

@stefan has joined the channel

@sorawee If you add the built catalog to the list of catalogs that raco pkg
uses by default, then it might check both. If you use --catalog
it will ignore all of the default catalogs and only use the one you specified, which won’t work if some packages are in that catalog and some aren’t. See the Dockerfiles of my racket images for details on how to set up the right configuration https://github.com/jackfirth/racket-docker\|https://github.com/jackfirth/racket-docker

(also if you try this, let me know how it goes and if anything went wrong or didn’t work)

I just took another look at the document. The type declaration seems legit.

I think what you need in your code is to call vector? before calling vector-ref

like (define v (if (vector? vs) (vector-ref vs i) <some-default vector>)

Thanks for the tip. I’ll keep it in mind. Inserting an explicit check often helps. For my code experiment I decided to use matrix->vector*
instead. It might be faster to use than the general array->vector*
. I am not sure though.

I don’t think there is a built-in way. I would write a simple macro to do the job.

Nice, that works perfectly! I guess the improvement here could be allowing multiple --catalog
flags? I tried that and it doesn’t work, so I thought only one catalog is supported at a time.

@andrew.giessel has joined the channel

Hello everyone, I’m currently working through Beautiful Racket. I’ve hit an error that I can’t figure out involving the use of #:unless. The code in question is here: https://beautifulracket.com/funstacker/the-rewrite.html#a_y4buf

:wave: howdy! Problem with cmdline
https://docs.racket-lang.org/reference/Command-Line_Parsing.html?q=cmdline#%28def._%28%28lib._racket%2Fcmdline..rkt%29._parse-command-line%29%29
The spec says that #:usage-help
can take a string or an expression that evals to a string:
help-spec = string
\| (string-expr ...+)
But when I try to slap in a variable containing a string I get an error:
(define help-text (~a "The following commands are available: " command-dirs))
...
(command-line
#:program "retriever"
#:usage-help help-text
...
command-line: #:usage-help clause contains non-string
at: help-text

The error is #%datum: keyword misused as an expression
, which suggests that its not defined.

ah, it’s a paren error. sorry about that!

@d_run the parens are “literal”. Try changing #:usage-help help-text
to #:usage-help (help-text)
?

no :game_die:
command-line: #:usage-help clause contains non-string
at: (help-text)

Oh wait

According to the grammar, the thing after #:usage-help
is not help-spec

#:usage-help string ...

gah

def need to able to slot generated content in there

I think you can hack this by using parse-command-line

and does quasiquote/unquote voodoo to make it work

aight

okay yup that worked, switching to parse-command-line
- thanks! I avoided that at first because the syntax is very hard to follow

@mflatt any idea how make site PKGS="typed-racket" SRC_CATALOG=../my-cat2
could fail because build/installers
does not exist? Full log attached. EDIT this is on a fresh clone. my-cat2
is from a raco pkg catalog-copy --from-config
using a Racket 7.5 I think

I think you’ll have to supply a CONFIG
argument to provide a configuration file that specifies clients. Otherwise, a default “build/site.rkt” is created with no clients specified — which doesn’t seem very useful, and maybe it should try to build a default configuration that specifies an installer via localhost.

Ok I’ll try that.
I don’t remember needing to give a config when I got a pkg-build running last December

Maybe you edited at the default “build/site.rkt” location, instead?

I think that would be a great improvement