Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kitlangton
Copy link
Member

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 😜

adamgfraser
adamgfraser previously approved these changes Mar 17, 2021
Copy link
Contributor

@adamgfraser adamgfraser left a 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!

@kitlangton
Copy link
Member Author

Thanks @adamgfraser!

Just realized, I didn't make these AnyVal, I think I could as long as I move the Tag requirement onto apply. The only issue with that is that one cannot define AnyVals on traits, so they'd all have to hang out on the bottom of the zio package object. Am I mistaken about that? If not, should I just move them there and AnyVal them up or leave them in a trait?

@adamgfraser
Copy link
Contributor

@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.

@kitlangton
Copy link
Member Author

Nice! I'll add the overloads then :)

@kitlangton
Copy link
Member Author

Overloaded 🔌 !

adamgfraser
adamgfraser previously approved these changes Mar 17, 2021
@neko-kai
Copy link
Member

neko-kai commented Mar 18, 2021

I thought case class companions extending Function goes away in Scala 3+ (replaced by implicit new)
See (scala/scala3#7207 (comment)), actually this is likely to continue working fine since they've handled this case

@kitlangton kitlangton force-pushed the function-to-layer branch 2 times, most recently from 4f9d2eb to e360611 Compare March 19, 2021 06:04
@kitlangton
Copy link
Member Author

kitlangton commented Mar 20, 2021

Whew, okay, changing it to (FooLive.apply _).toLayer will work on both. Good catch, @neko-kai! Now dotty_jdk8 is failing for the good reason.

However, maybe I should just open this against ZIO 1.0.0, as it's completely orthogonal and would be nice to have earlier.

@adamgfraser
Copy link
Contributor

If it can be binary compatible yes it is better to submit it against the 1.0 branch.

@CLAassistant
Copy link

CLAassistant commented Mar 21, 2021

CLA assistant check
All committers have signed the CLA.

@kitlangton kitlangton changed the base branch from series/2.x to master March 21, 2021 18:30
@kitlangton
Copy link
Member Author

Cherry-picked onto master 👍

@adamgfraser adamgfraser merged commit efc9f3c into zio:master Mar 25, 2021
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

Successfully merging this pull request may close these issues.

4 participants