-
Couldn't load subscription status.
- Fork 1.4k
Add type-inferrable toLayer extension on functions #4811
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very interesting use of case classes!
|
Thanks @adamgfraser! Just realized, I didn't make these |
|
@kitlangton I think I would leave it as you have it. The overhead of one additional allocation is going to be trivial compared to the cost of constructing even a simple layer. |
|
Nice! I'll add the overloads then :) |
1bd46d2 to
0abca60
Compare
|
Overloaded 🔌 ! |
|
I thought case class companions extending Function goes away in Scala 3+ (replaced by implicit |
4f9d2eb to
e360611
Compare
|
Whew, okay, changing it to However, maybe I should just open this against ZIO 1.0.0, as it's completely orthogonal and would be nice to have earlier. |
|
If it can be binary compatible yes it is better to submit it against the 1.0 branch. |
e360611 to
c08cbc0
Compare
|
Cherry-picked onto master 👍 |
Unlike
ZLayer.fromServices, this can completely infer the input types. It can save a lot of boilerplate in the common cases. I can also be used in interesting ways if we add a variant of>>>that is not required to fully satisfy the dependencies of the righthand side (e.g., #4772 (comment)).P.S. I'll go up to the magic number 22 and beyond. I just first want to make sure this is alright with everyone before giving myself unnecessary RSI 😜