jackfirth / rebellion

A collection of core libraries for Racket
https://pkgs.racket-lang.org/package/rebellion
Apache License 2.0
80 stars 16 forks source link

Cannot import define-record-type from rebellion or rebellion/type modules #489

Closed srcreigh closed 3 years ago

srcreigh commented 3 years ago

Thank you so much for the library!

I tried out the record types which have such a great API, but had a few false starts:

~/Library/Racket/7.6/pkgs/rebellion % racket
Welcome to Racket v7.6.
> (require rebellion)
> (define-record-type point (x y))
; define-record-type: undefined;
;  cannot reference an identifier before its definition
;   in module: top-level
; [,bt for context]
> (require rebellion/type)
; open-input-file: cannot open module file
;   module path: rebellion/type
;   path: /Users/shane/Library/Racket/7.6/pkgs/rebellion/type.rkt
;   system error: no such file or directory; rktio_err=3
; [,bt for context]
> (require rebellion/type/record)
> (define-record-type point (x y))
> (point #:x 1 #:y 2)
(point #:x 1 #:y 2)
> 

I expected (require rebellion) to import everything, and (require rebellion/type) to import all the type stuff.

The docs seem to encourage these import strategies here and here.

Any reason why not export everything for these higher level packages? I suppose there might be namespace collisions? Anyway, I can get started on a PR to do this if you like.

Thanks again for the great library.

jackfirth commented 3 years ago

Yup, the possibility of namespace collisions is why things aren't imported from the higher-level modules. It's happened before: symbol->immutable-string was added to racket recently (specifically racket/symbol, which racket exports) and that caused conflicts with rebellion/base/symbol. If rebellion exported everything, every module that imported both racket and rebellion would have broken. Requiring imports of each module limits the scope of breakages like that.

Really the only reason the docs mention the higher-level modules like rebellion and rebellion/type (which are empty and don't export anything) is so it's easy for me to search for a particular root section of the docs, and so it makes the module hierarchy clearer. There might be better ways to do that though, and maybe the docs should actually mention that those modules are empty.

jackfirth commented 3 years ago

Closing for inactivity. Feel free to reopen if you'd like to discuss further.