-
Notifications
You must be signed in to change notification settings - Fork 403
Add Gen.tailRecM #359
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
Add Gen.tailRecM #359
Conversation
|
okay, I am much more confident that this is correct now. |
|
|
||
| /** Build a pair from two generators | ||
| */ | ||
| def product[A, B](ga: Gen[A], gb: Gen[B]): Gen[(A, B)] = |
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.
The implementation is a bit different, but there is a zip method. Is this intended to be available in addition to that?
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.
honestly, I didn't know about it. I think this implementation is more efficient but I am happy to remove it (or change the zip 2 implementation to use this approach).
My main interest in the tailRecM.
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.
@johnynek just to provide some context for that last comment: I'm not a Scalacheck maintainer; I just happened to see this change and I was pretty sure that a method similar to product existed, so I thought that I would point it out. I have no opinions on how to proceed regarding product, but I certainly could see benefit in tailRecM existing.
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.
Let's remove product here and devote the energy to porting that strategy over to the generated zip implementations. I agree with @johnynek that this approach is probably more efficient, so let's definitely do that.
| seeds.forall { seed => | ||
| g1.pureApply(params, seed) == finalG2.pureApply(params, seed) | ||
| } | ||
| } |
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.
This is a great property!
|
Once we remove |
|
👍 |
These are two methods I often want with Gen.
I think the tailRecM is correct, but I don't know the internal implementation that well so happy to get any feedback on how to improve it.
cc @non