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

Skip to content

Conversation

@iravid
Copy link
Member

@iravid iravid commented May 1, 2020

No description provided.

@iravid iravid changed the title Zmanaged releasemap Redesign ZManaged around an embedded finalizer map May 6, 2020
@iravid
Copy link
Member Author

iravid commented May 6, 2020

@ioleo I'm fairly confident that ZLayer is constructed correctly now, but the mocking specs are still not passing. Any chance you could look into this?

}
}
def flatMap[R1 <: R, E1 >: E, B](f: A => ZManaged[R1, E1, B]): ZManaged[R1, E1, B] =
ZManaged(self.zio.flatMap { case (_, a) => f(a).zio })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the finaliser of the first effect important to keep here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. The finalizers returned from the underlying ZIO are only used for early release.

I'm wondering if the correct thing to do is only allow the resulting ZIO to be released early, or should an early release of the resulting ZIO should also release the flatMapped ZIO.

Will think about this. Thank you for pointing this out!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it's definitely right to compose the early release finalizers as well. Thanks @regiskuckaertz.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, I even did that without thinking for ZManaged.foreach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👌

@iravid iravid force-pushed the zmanaged-releasemap branch from c7c3d5e to 4961eea Compare May 7, 2020 12:01
@iravid iravid marked this pull request as ready for review May 7, 2020 19:29
)(zero: B)(f: (B, A) => B): ZIO[R, E, B] =
Ref.make(zero) >>= { acc =>
foreachParN_(n)(in) {
Predef.identity(_) >>= { a => acc.update(f(_, a)) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the Predef.identity? 😮

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s shadowed by ZIO.identity 🤷🏼‍♂️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry I misread. This is silly. Will fix.

I admit to just copying the mergeAllPar implementation 😂

release = finalizers.runAll
)
}
def zipWithPar[R1 <: R, E1 >: E, A1, A2](that: ZManaged[R1, E1, A1])(f: (A, A1) => A2): ZManaged[R1, E1, A2] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice simplification 😲

@regiskuckaertz
Copy link
Member

This is amazing

regiskuckaertz
regiskuckaertz previously approved these changes May 9, 2020
Copy link
Member

@regiskuckaertz regiskuckaertz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks gorgeous and ready to me 🕺🏻

adamgfraser
adamgfraser previously approved these changes May 9, 2020
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.

Looks incredible!

@iravid iravid dismissed stale reviews from adamgfraser and regiskuckaertz via 6f5d0b9 May 9, 2020 19:03
@iravid iravid force-pushed the zmanaged-releasemap branch from 6547336 to 6f5d0b9 Compare May 9, 2020 19:03
@iravid iravid merged commit a711808 into zio:master May 9, 2020
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