-
Notifications
You must be signed in to change notification settings - Fork 217
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 generic n-ary product shrinking #2999
Conversation
da5d94f
to
8617e1e
Compare
2a8756f
to
795d5f3
Compare
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.
Thanks for making this PR @sevanspowell!
LGTM.
bors r+ |
2999: Add generic n-ary product shrinking r=jonathanknowles a=sevanspowell - Translate the round-robin shrinking algorithm to work on n-ary products (types with one constructor [product types], with n constructor arguments), in the Generics.SOP universe. - Write a property to assert that the old selectionParams shrinker and the new one produce the same result. - Replace all instances of liftShrinkN with a generic alternative. See the following resource for more info on generics-sop: https://raw.githubusercontent.com/kosmikus/cufp-tutorial-2016/master/LectureNotes.pdf Co-authored-by: Samuel Evans-Powell <[email protected]> Co-authored-by: IOHK <[email protected]> Co-authored-by: Jonathan Knowles <[email protected]>
Build failed: Cached failure: https://hydra.iohk.io/build/8178016/nixlog/3/tail
|
- Translate the round-robin shrinking algorithm to work on n-ary products (types with one constructor [product types], with n constructor arguments), in the Generics.SOP universe. - Derive an instance of Generics.SOP.Generic for SelectionParams. - Replace shrinkSelectionParams with new version that uses generic shrinker function ("groundRobinShrink"). - Write a property to assert that the old selectionParams shrinker and the new one produce the same result.
Use 4n space indents for expressions. Use (4n+2) space indents for `where` clauses.
These operators allow us to define shrinkers with a syntax that is very similar to the applicative syntax for defining generators. For example: ```haskell genMyRecord :: Gen MyRecord genMyRecord = MyRecord <$> genFoo <*> genBar <*> genBaz shrinkMyRecord :: MyRecord -> [MyRecord] shrinkMyRecord = genericRoundRobinShrink <@> shrinkFoo <:> shrinkBar <:> shrinkBaz <:> Nil ```
We give it an increased possibility of generating zero values. This increases the probability that we'll generate a minimal test record.
49eec98
to
4cb2855
Compare
bors r+ |
2999: Add generic n-ary product shrinking r=jonathanknowles a=sevanspowell - Translate the round-robin shrinking algorithm to work on n-ary products (types with one constructor [product types], with n constructor arguments), in the Generics.SOP universe. - Write a property to assert that the old selectionParams shrinker and the new one produce the same result. - Replace all instances of liftShrinkN with a generic alternative. See the following resource for more info on generics-sop: https://raw.githubusercontent.com/kosmikus/cufp-tutorial-2016/master/LectureNotes.pdf Co-authored-by: Samuel Evans-Powell <[email protected]> Co-authored-by: IOHK <[email protected]> Co-authored-by: Jonathan Knowles <[email protected]>
Build failed: Cached failure: https://hydra.iohk.io/build/8178016/nixlog/4/tail Same problem as before:
|
This commit is intended to fix the following Windows build error: https://hydra.iohk.io/build/8178016/nixlog/4/tail
bors r+ |
2999: Add generic n-ary product shrinking r=jonathanknowles a=sevanspowell - Translate the round-robin shrinking algorithm to work on n-ary products (types with one constructor [product types], with n constructor arguments), in the Generics.SOP universe. - Write a property to assert that the old selectionParams shrinker and the new one produce the same result. - Replace all instances of liftShrinkN with a generic alternative. See the following resource for more info on generics-sop: https://raw.githubusercontent.com/kosmikus/cufp-tutorial-2016/master/LectureNotes.pdf Co-authored-by: Samuel Evans-Powell <[email protected]> Co-authored-by: IOHK <[email protected]> Co-authored-by: Jonathan Knowles <[email protected]>
Build failed: Cached failure... 🙄 I've restarted the failed job, and this time it passed. I'll wait for all jobs to succeed on hydra before restarting the merge. |
bors r+ |
Build succeeded: |
with one constructor [product types], with n constructor arguments), in the
Generics.SOP universe.
one produce the same result.
See the following resource for more info on generics-sop: https://raw.githubusercontent.com/kosmikus/cufp-tutorial-2016/master/LectureNotes.pdf