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

Fix ambiguous use of OVERLAPPING instances in genericShrink #370

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

MaximilianAlgehed
Copy link
Collaborator

As per the following documentation for how OVERLAPPING resolves (that I'm 99% sure is the same across all GHC versions) https://downloads.haskell.org/~ghc/7.10.1/docs/html/users_guide/type-class-extensions.html#instance-overlap
the way that ghc resolves OVERLAPPING pragmas is that an instance that is OVERLAPPING will be chosen over one that isn't. It's not clear why the old code ever worked, possibly because GSubtermsIncl (K1 i a) a is a substitution of GSubtermsIncl (K1 i a) b...

Anway, with this change it's explicit that the GSubtermsIncl (K1 i a) a instance will be chosen over the GSubtermsIncl (K1 i a) b instance.

@MaximilianAlgehed
Copy link
Collaborator Author

While this does not alleviate the concern in #84 about GHC picking the "shrink to empty list" instance when it can't conclude that two types are equal, it does make the rules for choosing instances more clear. I'm not convinced that the issue raised in #84 is real, however.

@Lysxia
Copy link
Contributor

Lysxia commented Mar 20, 2024

It's not clear why the old code ever worked, possibly because GSubtermsIncl (K1 i a) a is a substitution of GSubtermsIncl (K1 i a) b...

Yes, that's why. The extra OVERLAPPING annotation was not ambiguous, but unnecessary.

@MaximilianAlgehed MaximilianAlgehed merged commit 60a95f7 into master Mar 21, 2024
108 checks passed
@MaximilianAlgehed MaximilianAlgehed deleted the PR-fix-overlapping branch March 21, 2024 08:32
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.

3 participants