-
Notifications
You must be signed in to change notification settings - Fork 9
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
Kitchen Sink import #2
Comments
Somewhat hampered by: scalameta/metals#4325 It's going to be hard to strike a balance here, and arguably some of the import complaints should be resolved by the libraries themselves rather than One aspect of the import complaints is that, usually the answer is: import |
IMHO a good fit might be this 👇 package typelevel.toolkit
export cats.syntax.all.*
export cats.effect.*
export fs2.* but I'll confirm what I'm saying after I'll have the time to enucleate all the stuff that will get imported in this way. |
I think I'm going to use enucleate in daily life :P. In all seriousness, that looks good to me! |
my only issue is that with |
That's totally true, but (thinking out loud) isn't that solvable adding |
Note that |
I think the answer here is, don't do that :) instead of a wildcard we should export very specific things, like |
Discussing with @armanbilge, we came up with the idea that a Kitchen Sink import is probably not a great idea because it can be confusing for beginners progressing past the "hello world" with the TL stack. Code written relying on this kitchen sink import won't be copy-pastable to other codebases as imports may need to be added. If this may not represent a problem for users proficient with the toolkit's libraries, beginners may struggle to compile the code as it may even happen that the IDE won't cooperate. Last but not least, at the import level, the examples in the toolkit homepage will be different from those in every included repository. We're trying to achieve higher ergonomics at the cost of clarity/compatibility. It may not be the correct way or place to solve the "lots of imports" problem. WDYT? |
Since the import is opt-in, I think it's okay if we entertain the idea. But reading the downsides you listed, it's a net-negative for me. Especially the copy-pastability of scripts hurts most :(. |
I think the best long-term strategy is that we should keep pursuing ways to reduce the number of imports necessary overall in the various libraries. At present we are in a really annoying spot, but somewhere in the future we can define syntax directly on typeclasses, so that the syntax imports are no longer necessary. |
Here's a contributors thread by @benhutchison on this topic!
https://contributors.scala-lang.org/t/idiomatic-imports/5788/1 |
I was also reminded of this. |
Yea the import problem and discovery of things is really mehh. But reading through the thread it seems a more powerful |
TBH I think Martin has a point in saying "you are establishing a DSL that only an expert can be comfortable in" while talking about Also, to cite Ben:
IMHO, the What Daenyth did in the CE prelude was the scala 3 export alternative that I had in mind while looking at this issue. I'm on the same page as @zetashift: I think that overall re-namespacing the most used classes/data structures/syntaxes may have a net-negative impact. |
Actually, my experience is that IDE automation falls far short my ideal wish-list around imports. And this is in large part because the problem is hard. Example. If you didn't already have Similarly, if you activate code completion, you will not see extension method options unless they were already imported. But often the biggest challenge is discovering what extensions exist and how to import them. Finally, neither IDE is yet smart enough to make decisions about whether added Scala 3 imports should be |
As a small update, with the recent improvements of toolkit and typelevel being a kit, I don't have anything else to complain(things are nice! :P) about except for the imports issue across Typelevel ecosystem. A |
I thought so many times to publish a toolkit + a Prelude under my group id just to test out if this solution works for my day by day 🤔 I'll do it eventually |
A common complaint is about the enormous amount of imports it takes to do stuff. e.g. http4s/http4s#6696
What if ... we just exported a bunch of useful stuff under a single package?
Not gonna lie, it's playing with fire a bit. Probably instead of wildcards we should be thoughtful about the specific things we export.
But then:
and you are off to the races!
The text was updated successfully, but these errors were encountered: