-
Notifications
You must be signed in to change notification settings - Fork 109
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
Improved, and dare I say minimal, shrinking of lists #276
Conversation
@@ -305,9 +363,20 @@ class Monad m => MonadGen m where | |||
-- | |||
freezeGen :: m a -> m (a, m a) | |||
|
|||
instance Monad m => MonadGen (GenT m) where |
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.
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.
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.
In the 99% case, users will just use Gen
by virtue of the type of forAll
and not worry about any of this.
043d74f
to
365a03f
Compare
cc9c3d1
to
d0d2f60
Compare
d0d2f60
to
a233ebe
Compare
a233ebe
to
7cf1baf
Compare
Updated description with details |
Good stuff 馃榿 |
Crazy stuff 馃殌 |
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 oftoGen
/fromGen
. This comes at the cost ofStateT
andRWST
instances, but you can still run these on the inside of the transformer and get aMonadGen
, it's just slightly less conveniant. If anyone can figure out how to implementMonadTransControl
forTreeT
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! 馃帀