Skip to content

Build failure with GHC 9.2.1 #32

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

Closed
sjakobi opened this issue Nov 11, 2021 · 7 comments · Fixed by #34
Closed

Build failure with GHC 9.2.1 #32

sjakobi opened this issue Nov 11, 2021 · 7 comments · Fixed by #34
Labels
build Build failures (usually from GHC upgrades)

Comments

@sjakobi
Copy link

sjakobi commented Nov 11, 2021

src/Generic/Random/Internal/BaseCase.hs:191:3: error:
    • Could not deduce (Alternative (IfM y Weighted Proxy))
        arising from the superclasses of an instance declaration
      from the context: (GBCSSum f g z e yf yg, GBCS f z yf e,
                         GBCS g z yg e, y ~ (yf ||? yg))
        bound by the instance declaration
        at src/Generic/Random/Internal/BaseCase.hs:(191,3)-(195,27)
    • In the instance declaration for ‘GBCS (f :+: g) z y e’
    |
191 |   ( GBCSSum f g z e yf yg
    |   ^^^^^^^^^^^^^^^^^^^^^^^...

src/Generic/Random/Internal/BaseCase.hs:239:3: error:
    • Could not deduce (Alternative (IfM y Weighted Proxy))
        arising from the superclasses of an instance declaration
      from the context: (GBCSProduct f g z e yf yg, GBCS f z yf e,
                         GBCS g z yg e, y ~ (yf &&? yg))
        bound by the instance declaration
        at src/Generic/Random/Internal/BaseCase.hs:(239,3)-(243,27)
    • In the instance declaration for ‘GBCS (f :*: g) z y e’
    |
239 |   ( GBCSProduct f g z e yf yg
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^...
cabal: Failed to build generic-random-1.5.0.0
@sjakobi
Copy link
Author

sjakobi commented Nov 11, 2021

I'm getting the same error with all the versions from v1.2.0.0 and up.

I'm wondering whether I should add Hackage revisions to add bounds base < 4.16 for these versions, but I'm actually not sure whether the problem is in this library or in GHC.

@Lysxia Lysxia added the build Build failures (usually from GHC upgrades) label Nov 11, 2021
@Lysxia
Copy link
Owner

Lysxia commented Nov 11, 2021

Huh, that seems to be a regression coming from GHC. In any case it wouldn't hurt to add the bounds to the released versions that broke, would it?

@Lysxia
Copy link
Owner

Lysxia commented Nov 11, 2021

I opened a GHC ticket with a minimized example https://gitlab.haskell.org/ghc/ghc/-/issues/20666

@sjakobi
Copy link
Author

sjakobi commented Nov 11, 2021

Thanks!

I have made the Hackage revisions, e.g. https://hackage.haskell.org/package/generic-random-1.5.0.0/revisions/.

Once there's fixed GHC 9.2.x, we can probably relax these again.

@goldfirere
Copy link
Contributor

#34 contains the fix.

GHC uses a sizing scheme to ensure that it does not create bottom dictionaries. When trying to verify that an instance's superclass constraints are satisfied, it will use superclass constraints extracted from smaller instance context constraints. In the two instance declarations patched in #34, both the relevant instance constraint and the instance head (the part to the right of the =>) have size 6, so GHC won't use the superclass of the instance constraint. Maybe it's possible to do some syntactic manipulation to get the sizes to be different, but there seems little harm in just adding the redundant constraint (which is, happily, backward compatible).

The fact that older GHCs accepted the instances was a bug. I'm fairly sure that it would have been possible to create bottom dictionaries.

@Lysxia
Copy link
Owner

Lysxia commented Nov 23, 2021

Thanks for the detailed explanation Richard!

@sjakobi I released the fix in 1.5.0.1

@sjakobi
Copy link
Author

sjakobi commented Nov 23, 2021

Thank you, @Lysxia and @goldfirere! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build failures (usually from GHC upgrades)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants