Shortcut generation for map/bind with lazy small_example #66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This proposal might not be the right bandage (maybe just expanding the documentation of
choose
would be better.) I ran into some issues with a recursive generator that was failing to terminate. Reading crowbar source code, there's asize
fuel mechanism in place to shortcut the random generation by choosing the first availableconst
/primitive
when the generated term grows too much -- but my leaves were wrapped in amap [..]
and so the shortcut couldn't trigger (for example, see the xmldiff test where knowledge of the optimization edge-case yields a manual unrolling).Some random comments:
small_examples
was a list of candidates, but then the shortcut would always pick the first one (such that it could have been anoption
):crowbar/src/crowbar.ml
Line 246 in 0cbe3ea
Perhaps the plan was to select a random value from that list? (but the current behavior has the advantage of not consuming more random bits)
choose
would previously crash at this point:crowbar/src/crowbar.ml
Line 252 in 0cbe3ea
Perhaps
Choose []
could be simplified away by the smart constructors -- but this would push the "non-empty generator" constraint tounlazy
/bind
, it's not clear that this would be better.const
/primitive
as before, and default to themap
/bind
otherwise (but I think it's easier to predict the default value when it's always the first element ofchoose
)afl-fuzz
is able to avoid triggering it too much?(unrelatedly, the
xmldiff
test seems to work on my computer -- however thecalendar
test crashes very fast!)