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

Change Applicative GenT to use zipping #272

Merged
merged 3 commits into from
Apr 24, 2019

Conversation

jacobstanley
Copy link
Member

@jacobstanley jacobstanley commented Apr 23, 2019

This changes the Applicative instance for GenT so that it zips the tree rather than binding it. This means that a generator like (,) <$> genA <*> genB will be able to alternate between shrinking genA and genB rather than doing one first and then the other.

An example shrink tree using a zipping approach vs just using (<*>) = ap:

Screenshot 2019-04-23 at 2 35 55 PM

I had it like this originally and changed it because it broke the law <*> = ap, but I'm not sure this is that important as the Monad instance for GenT is already unlawful.

Haxl also uses an unlawful Applicative instance for basically the same reason. This was the motivation for ApplicativeDo which you would be able to use with Hedgehog after this patch to achieve more optimal shrinking.

A nice article explaining another option and the tradeoffs: https://elvishjerricco.github.io/2016/09/17/abstracting-async-concurrently.html

I also renamed Tree to TreeT, so I could have Tree = TreeT Identity as I was working with TreeT Identity a lot during testing and it got a bit tedious.

@jacobstanley jacobstanley force-pushed the topic/parallel-shrinking branch 5 times, most recently from 52eadc8 to b08ff0c Compare April 23, 2019 22:48
charleso added a commit to hedgehogqa/scala-hedgehog that referenced this pull request Apr 23, 2019
charleso added a commit to hedgehogqa/scala-hedgehog that referenced this pull request Apr 23, 2019
charleso added a commit to hedgehogqa/scala-hedgehog that referenced this pull request Apr 23, 2019
@jacobstanley
Copy link
Member Author

hmm can't use CPP #ifdef with language extensions, weird

charleso added a commit to hedgehogqa/scala-hedgehog that referenced this pull request Apr 24, 2019
@jacobstanley
Copy link
Member Author

It's wild that the scala commits are showing up here, pretty cool

@jacobstanley
Copy link
Member Author

I decided requiring transformers >= 0.5 was a lesser evil than dropping 7.10 support.

7.10 has been a real pain recently though, these last few PRs always seem to have some issue.

It is pretty old now! Version 7.10.3 (released 8th December 2015)

@jacobstanley jacobstanley merged commit dea7d6d into hedgehogqa:master Apr 24, 2019
@jacobstanley jacobstanley deleted the topic/parallel-shrinking branch April 24, 2019 03:33
@moodmosaic
Copy link
Member

I guess we should consider dropping GHC 7.* when GHC 9.* comes out, which might not be so far away given the increased GHC release cycles.

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

2 participants