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

Duplicates in shrink trees for maybe #118

Closed
enolan opened this issue Sep 6, 2017 · 3 comments
Closed

Duplicates in shrink trees for maybe #118

enolan opened this issue Sep 6, 2017 · 3 comments

Comments

@enolan
Copy link

enolan commented Sep 6, 2017

The shrink tree for this generator contains several duplicates:

$ stack ghci --package hedgehog --resolver lts-9.2
Configuring GHCi with the following packages: 
GHCi, version 8.0.2: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /tmp/ghci18165/ghci-script
Prelude> import Hedgehog
Prelude Hedgehog> import qualified Hedgehog.Gen as Gen
Prelude Hedgehog Gen> Gen.print $ Gen.maybe Gen.latin1
=== Outcome ===
Just 'T'
=== Shrinks ===
Nothing
Just 'T'
Just 'T'
Just 'T'
Just 'T'
Just '\NUL'
Just '*'
Just '?'
Just 'J'
Just 'O'
Just 'R'
Just 'S'

This slows down shrinking a lot. I think the culprit is maybe, you get reasonable shrinks from latin1 on its own.

@jacobstanley
Copy link
Member

I'm not sure how to avoid this in the generators themselves, but perhaps we can build some things in to the tree to prevent duplicate entries if you're finding that shrinking is slowed down a lot by this.

@TysonMN
Copy link
Member

TysonMN commented Nov 9, 2020

@HuwCampbell said in #406 (comment) that issue was fixed by that PR. Does someone want to test if this issue is gone?

@moodmosaic
Copy link
Member

@TysonMN, here are some sample outputs:

λ Gen.print $ Gen.maybe Gen.latin1
=== Outcome ===
Just '@'
=== Shrinks ===
Nothing
Just '\NUL'
Just ' '
Just '0'
Just '8'
Just '<'
Just '>'
Just '?'
λ Gen.print $ Gen.maybe Gen.latin1
=== Outcome ===
Just 'S'
=== Shrinks ===
Nothing
Just '\NUL'
Just '*'
Just '?'
Just 'I'
Just 'N'
Just 'Q'
Just 'R'

It appears that #406 closes this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants