Main file name of module in https://pkgs.racket-lang.org/

Bonjour,

i have a question about Racket's package.

First due to another answer in a thread i have to say,once and only,that i do not respond to false answer about any of my project that would lead to polemic's long and unecessary discussion.

I'm not here to have polemic discussion, this is not my interest.
(Even more when solution are written in non standart scheme (not RnRS) that i can not reuse in another scheme implementation and are of no use for me as i intend to write portable code.)

Now my question about module in https://pkgs.racket-lang.org/ .
i have a directory, supposing name foo containing bar.rkt which is a racket module.
when i download it from https://pkgs.racket-lang.org/ i can use it only this way:

(require foo/bar)

this works. But it has the constrainst to be directory/filename . For example if i convert the project in R6RS i will use (import (foo bar) ...
i just want like any other module to be able to do :
(require foo) in Racket
or in R6RS (import (foo) ...

i find this is working , as raco require the filename of module to be always main.rkt.
That is if i rename bar.rkt in main.rkt it works.

but is there a way to change that, i want to keep my custom project main filename to bar.rkt for example ,not main.rkt.

Is there a way to configure the package ,in info.rkt file ? or anywhere to do that?

Regards,

As far as I know:

Bad news: You'll need to supply a main.rkt.

Good news: It can just re-provide bar.rkt. For example:

#lang racket/base
(require "bar.rkt")
(provide (all-from-out "bar.rkt"))

This is actually a fairly common practice in Racket libraries -- to have a main.rkt that does nothing but re-provide other modules. Sometimes everything from a module (all-from-out), or sometimes just select items.

(There's even a #lang reprovide to make this less verbose. :smile:)

p.s. Another convention is to have many modules under a private directory. This signals to people that, although they can require stuff from there, it's "at their own risk"; it's implementation details that someday might change or disappear. Whereas normally the convention in Racket is to be backward compatible, forever. So main.rkt is sort of "public API.rkt".

Anyway, I mention this as another example where the main.rkt exists solely to re-provide things.

4 Likes

i wanted to make it the Racket way:

the main.rkt :

#lang reprovide
"src/Scheme+.rkt"

i waited the auto-packaging to be done to be sure it worked and it is just successfully packaged:

forgot to say i had to add reprovide-lang-lib in the info.rkt file:

(define deps '("base"
	       "srfi-lib"
	       "sci"
	       "r6rs-lib"
	       "reprovide-lang-lib"))