Skip to content
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

Integrated shrinking #22

Open
1Jajen1 opened this issue Nov 2, 2019 · 0 comments
Open

Integrated shrinking #22

1Jajen1 opened this issue Nov 2, 2019 · 0 comments
Milestone

Comments

@1Jajen1
Copy link
Owner

1Jajen1 commented Nov 2, 2019

Benefits:

  • A user would not have to write a shrinking function for most if not all data-types
  • Shrinking automatically follows invariants by construction. This reduces duplication in logic that checks/maintains those when manually shrinking
  • Allows to get rid of Arbitrary which is in itself not a big problem, but jut a hassle to implement, carry around and lookup.
  • Since shrinking is coupled to generators and changes to gen also change shrinking, which is a good thing if for example range is changed you'd not want shrunk results to be outside of that range

This comes with a few drawbacks:

  • When two generators are combined monadically they are shrunk one after the other and if the first one fails to shrink it will not be shrunk again. This can be overcome with using Applicative combinators wherever possible. Yet another way to overcome this is to simply add back a shrinker. While certainly not great, it gives the same level of control as type based shrinking (Or at least I think it does)
  • Generating functions relies on Coarbitrary and Function and some unsafe methods. I do not want to loose generating functions so there must be a way. I'd be fine keeping the typeclasses for the two, also the unsafe methods, but this needs to be done in a way that still allows integrated shrinking to work

My take on this atm is: Convenience over the best possible shrinking (which can still be recovered by extra work if needed). I'll start playing around with integrated shrinking once the internal rewrite is done.

This is a very good resource on the differences between the two and their drawbacks: http://www.well-typed.com/blog/2019/05/integrated-shrinking/#fnref10

@1Jajen1 1Jajen1 added this to the 1.0 Stable milestone Nov 2, 2019
@1Jajen1 1Jajen1 mentioned this issue Nov 2, 2019
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant