-
Notifications
You must be signed in to change notification settings - Fork 156
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
Support Gen.pick
by analogy to Seq.pick
#625
Comments
Appreciate the idea @brianberns. I understand the utility of Implementation wise, would something like The situation in FsCheck is a bit more complicated than for Lastly, for With all that (ease of implementation + likely problematic in common use cases + non-trivial API impact), do you still feel the added utility outweighs the cost? |
Thank you for the thoughtful response.
I tend to avoid
I definitely agree with this. However, there are cases where it can't reasonably be avoided. In those cases, I think it makes sense to think of a generator as producing a stream of potential values, much like
Yes, if you decide to include |
I'm fairly agnostic about this suggestion, but tend to agree with @kurtschelfthout that filtering should be avoided in most cases. (And then there are some rare cases where it makes sense.)
I tend to be curious when encountering claims like that. This may risk derailing the discussion, but would you mind sharing an example? |
Sure. I'm working on a compiler that does type inferencing, which relies on a unification algorithm. Two types can be unified if there is a substitution that can be applied to both types to make them equal. My unit test generates pairs of types that can be unified and then verifies that the substitution does indeed produce equal types. I don't know how to do this constructively (i.e. without filtering), but I'm certainly open to suggestions. |
That's what I get for asking 😅 That's not really in my wheelhouse, but in any case it's hard to suggest alternatives without code. |
Seq.pick
is a very useful function that applies a given "chooser" function to successive elements, returning the firstx
where the function returnsSome x
. By analogy, I think FsCheck should provide a similar function. Here's a simple implementation that demonstrates the idea:The text was updated successfully, but these errors were encountered: