-
Notifications
You must be signed in to change notification settings - Fork 120
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
Speed up heavy use of mapTotalResult #415
base: master
Are you sure you want to change the base?
Conversation
7f4750e
to
bc20ad3
Compare
Unfortunately this doesn't work! Example:
Note that QuickCheck fails to print the counterexample. The reason is that Many QuickCheck combinators could have this problem, so the approach we ended up taking is to make quickcheck/src/Test/QuickCheck/Property.hs Lines 49 to 76 in d66336c
|
Isn't the solution here to only re-install the exception handler in the case where you go from something polymorphic to Property - that way we wouldn't have to re-apply the protection to something of type property? |
That would be reasonable, but it doesn't help in this case, does it? |
Yes, so it would apply it the first time, but when tabulate is applied to something that is already of type property, we don't need to apply the protection again? |
Isn't that what your patch already does, though? |
I don't get it, did you run your counterexample above on this branch? Because I really cannot see how that would succeed on master but fail on this branch? |
Yep, on master I get a slightly different output - note the
What's happening is that
and |
Right! But you only need one exception handler when you do |
Yes that's true! But if it's I have an idea how to do that, let me write it up... |
Right, here goes. Note that when I talk about "bottom" here, I really mean "crashing" - I've not thought about non-terminating properties. Call a value of type Note that any well-behaved Property does not need protecting. (In particular, we already maintain invariants that mean that a non-bottom rose tree must produce a non-bottom result.) We'd like to maintain the invariant "every
Then we can make protecting a property a no-op as long as the property is non-bottom:
The point is that if applying |
I like that idea a lot! I can try to implement this on the branch tomorrow - and I'll try to make a failing test of your "no counterexample" property too. I've been thinking, wouldn't it be nice to write some QuickCheck properties to check the strictness properties of QuickCheck - one could have a little DSL that compiles to |
What I fail to understand here is why in your example the |
Hmm, in this case I think (?) it works because And yes, strictness properties would be very nice! |
Ah yes, in `Gen` you get `do x <- bottom; protectProp x = protectProp
bottom` or something like that...
Sincerely
Maximilian Algehed, Ph.D.
…On Wed, 25 Sept 2024 at 18:07, Nick Smallbone ***@***.***> wrote:
Hmm, in this case I think (?) it works because fmap is in the Gen monad
which is lazy (fmap f gen = MkGen (\g n -> f (unGen gen g n))). But I
could be wrong :) In any case it's probably clearer to explicitly return a
failing result there.
And yes, strictness properties would be very nice!
—
Reply to this email directly, view it on GitHub
<#415 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACBPPQPBU3KF5EWZOBQQ5PTZYLNVRAVCNFSM6AAAAABOTVRIASVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZUGUYTINZZGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@nick8325 we are very confused about what's going on here.
mapTotalResult
results in repeated calls toproperty
on something of typeProperty
. This in turn results in repeated layers ofprotectProp
which causes properties that do a lot of tabulate or other similar things to blow up.Now, our intuition is that it should be fine to only do the
protectProp
once, when we run the property. Is this correct? What was the reason for the convoluted instance? No tests fail if you just doproperty = id
and nothing else...Thoughts very much welcome.