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

Consider exporting @data from Moshi.Data and @match from Moshi.Match #18

Open
MasonProtter opened this issue Aug 28, 2024 · 3 comments
Open

Comments

@MasonProtter
Copy link

I think it'd be good if by default Moshi.Data exported @data and Moshi.Match exported @match. Then a user in the REPL can quickly write in one line

using Moshi.Data, Moshi.Match

This way, @data and @match still aren't exported from Moshi itself by default, but there's an easy way to bring them into the namespace with less typing.

@Roger-luo
Copy link
Owner

See #12. I don't like exporting things by default, but I can consider supporting using Moshi.Prelude, which exports all public APIs into namespace.

cc: @jariji

@MasonProtter
Copy link
Author

I really disagree with the idea of not exporting things. IMO, expected APIs should be exported because it's very useful for the REPL and other interactive use-cases.

It should be the responsibility of packages to avoid regular using and instead write things like

using Moshi.Data: Data, @data

Also, we don't need to necessarily export @data and @match from Moshi, we can just export them from Moshi.Data and Moshi.Match.

@Roger-luo
Copy link
Owner

Roger-luo commented Aug 28, 2024

I really disagree with the idea of not exporting things. IMO, expected APIs should be exported because it's very useful for the REPL and other interactive use-cases.

I'm afraid I have to disagree with this. People are lazy by default. Exporting things by default would encourage downstream package authors to write a lot of using XXXX instead of using XXXX: abc. This has been something quite annoying maintaining MLStyle-based packages. It has been proven to be the case when collaborating within many packages, people just tend to be lazy and use excuse that I will come back. And the people being lazy here includes myself.

I do not see Moshi serving primarily for REPL. I build the package for more serious and much larger projects. It makes sense for a package primary serve for low-code development and notebook to export a lot of things by default, which is when using XXX exports a lot of names makes sense.

Thus I have to insist on the idea of no export by default unless extra words are being typed for a developer focused package like Moshi. And I believe Moshi.Prelude (if supported) does what you want in REPL with fewer types than using Moshi: @data, @match. And having this interface indicates the existence of the names @data, and @match inside Moshi.

See how interfaces are created here: https://github.com/Roger-luo/Jieko.jl

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