-
Notifications
You must be signed in to change notification settings - Fork 155
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
Nested tuples reduce diversity of samples #507
Comments
I'm not familiar with the internals of the default tuple generator, but I think that it divides a size between elements of a tuple. For example, if an initial size is 100 then elements of a 2-tuple will be (roughly) of size 50, and if these elements are also 2-tuples, then their elements will be of size 25 and so on. Thus until |
It makes sense. I guess it would need to have a check for types with just one value so it doesn't halve the size. |
What @Kharacternyk says is exactly correct. This is a somewhat pessimistic strategy to keep the total size of the outer tuple under the max desired size. You are right however that the actual used size in the tuple elements is not fed back to the outer tuple generator, because most types' size is effectively large enough for it not to be a concern. I.e. to generate an |
To follow up on that, to address this the tuple generator (or really any composite generator) would have to somehow be able to calculate the max usable size of its elements. And then use that to divide size. There are ways to do that - by writing combinators for "enumerable structures" with primitives much like the ones FsCheck generators have, but that allow to calculate properties of the resulting structures, such as their cardinality, there are techniques to efficiently generates an element of a given size with a guaranteed uniform distribution and so on. If I'd ever have time to write a new generation of FsCheck, that's where I'd start. A decent entry point is https://lara.epfl.ch/~kuncak/papers/KurajETAL15ProgrammingEnumerableSetsStructures.pdf and anything about combinatorics, esp. Species. |
Closing as dup of #507 |
It's a dup of itself? |
Dup of #444 |
That's not a quick question :) or even one I know the answer to. Open an issue with a repro. |
When generating samples with many unary nested types (like unit) the samples become highly repetitive:
Produces great samples:
But when tupled a little:
produces a degraded sample:
Fully nested tuples:
And all 100 samples are like these:
The text was updated successfully, but these errors were encountered: