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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved, and dare I say minimal, shrinking of lists #276

Merged
merged 2 commits into from
Apr 28, 2019

Conversation

jacobstanley
Copy link
Member

@jacobstanley jacobstanley commented Apr 25, 2019

This PR provides significantly improved shrinking of lists, I believe Hedgehog should now offer virtually minimal shrinking in this area. The change is that now the list shrink tree can alternate between shrinking the list and shrinking the elements. Before it would shrink all the elements first, and then it would try to shrink the list.

We also simplify MonadGen significantly, with all functions being implemented in terms of toGen / fromGen. This comes at the cost of StateT and RWST instances, but you can still run these on the inside of the transformer and get a MonadGen, it's just slightly less conveniant. If anyone can figure out how to implement MonadTransControl for TreeT then they will be easy possible on the back of that.

Many thanks to @edsko 馃挴 for the detailed discussions about the improvements offered here, and for his implementation of interleave for trees with monadic effects, that is a nut I've been trying to crack for many years now. It is quite a relief to have it solved! 馃帀

@@ -305,9 +363,20 @@ class Monad m => MonadGen m where
--
freezeGen :: m a -> m (a, m a)

instance Monad m => MonadGen (GenT m) where
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We remove the MonadGen instance for GenT, so the combinators in Hedgehog.Gen will now only work on Gen or transformers including Gen as the base monad.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the 99% case, users will just use Gen by virtue of the type of forAll and not worry about any of this.

@jacobstanley jacobstanley force-pushed the topic/tree-interleave branch 2 times, most recently from 043d74f to 365a03f Compare April 28, 2019 03:05
@jacobstanley jacobstanley force-pushed the topic/tree-interleave branch 2 times, most recently from cc9c3d1 to d0d2f60 Compare April 28, 2019 07:29
@jacobstanley jacobstanley changed the title WIP: Support for interleaving trees Support for interleaving trees Apr 28, 2019
@jacobstanley jacobstanley changed the title Support for interleaving trees Improved, and dare I say minimal, shrinking of lists Apr 28, 2019
@jacobstanley
Copy link
Member Author

Updated description with details

@edsko
Copy link
Contributor

edsko commented Apr 28, 2019

Good stuff 馃榿

@moodmosaic
Copy link
Member

Crazy stuff 馃殌

@jacobstanley jacobstanley merged commit ff11493 into hedgehogqa:master Apr 28, 2019
@jacobstanley jacobstanley deleted the topic/tree-interleave branch April 28, 2019 20:52
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

Successfully merging this pull request may close these issues.

None yet

3 participants