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

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Gen#zipWith describes combining two generators in a pairwise fashion. We ran into an issue where doing so was leading to generated values not being deterministic because in ZStream#zipAllWith we pull from the two streams in parallel so we could potentially evaluate the random effect in the second stream before the first stream. It would be nice to be able to describe combining streams point wise while evaluating the effects of pulling from the two streams sequentially versus in parallel.

To support this I added a new zipAllWithExec operator that takes an execution strategy and implemented zipAllWith in terms of that. Then we can call zipAllWithExec from Gen#zipWith to regain deterministic generated values.

@adamgfraser adamgfraser requested a review from iravid as a code owner September 24, 2020 04:05
iravid
iravid previously approved these changes Sep 24, 2020
Copy link
Member

@iravid iravid left a comment

Choose a reason for hiding this comment

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

Great addition 👍🏻

*/
def zipAllWithExec[R1 <: R, E1 >: E, O2, O3](
that: ZStream[R1, E1, O2]
)(left: O => O3, right: O2 => O3)(both: (O, O2) => O3)(exec: ExecutionStrategy): ZStream[R1, E1, O3] = {
Copy link
Member

Choose a reason for hiding this comment

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

Should we place the strategy’s parameter list first so that the functions are still specified last?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! Will change now.

@adamgfraser adamgfraser merged commit 338e6db into zio:master Sep 24, 2020
@adamgfraser adamgfraser deleted the deterministic branch September 24, 2020 05:33
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.

2 participants