Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

require/typed duplicates effects from expanding m; docs unclear #1378

Open
LiberalArtist opened this issue Jun 15, 2024 · 1 comment
Open

Comments

@LiberalArtist
Copy link
Contributor

What version of Racket are you using?

8.12 [cs]

What program did you run?

#lang typed/racket
(module untyped racket/base
  (define five 5)
  (define six 6)
  (provide (all-defined-out)))
(require racket/require)
(require/typed
 (filtered-in (begin (displayln "effect!") values) 'untyped)
 [five Byte]
 [six Byte])

What should have happened?

It should have printed:

effect!

But instead, it printed:

effect!
effect!

Discussion

The documentation says that "m [the first subform of require/typed] is a module spec", but the docs don't define "module spec". In the cases I've tried, it seems to mean a require-spec in the sense of require.

If "module spec" is supposed to mean require-spec, one solution might be to use expand-import, or local-expand to #%require, then rewrite the repeated (require (only-in m [old new])) forms to something like (#%require (rename m* new old)).

Alternatively, if "module spec" is supposed to mean something else—e.g. a module path—that requirement should be enforced and documented.

In any case, in the documentation, I think the first sentence of the "Require" documentation section, "Here, m is a module spec, pred is an identifier naming a predicate, and maybe-renamed is an optionally-renamed identifier.", should be moved under the blue box for require/typed, rather than above it: I missed it when jumping to the documentation for require/typed. I also think a cross-reference link to whatever "module spec" is supposed to mean would be helpful.

I ran into this while looking into a question on Discourse, so there is some concrete interest in the functionality of a general require-spec.

@racket-discourse-github-bot

This issue has been mentioned on Racket Discourse. There might be relevant details there:

https://racket.discourse.group/t/how-to-require-with-prefix-in-typed-racket/2963/7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants