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

Build failure on GHC 9.8.1: 'Illegal invisible type variable binder' #2567

Closed
Vekhir opened this issue Feb 18, 2024 · 7 comments · Fixed by #2622
Closed

Build failure on GHC 9.8.1: 'Illegal invisible type variable binder' #2567

Vekhir opened this issue Feb 18, 2024 · 7 comments · Fixed by #2622

Comments

@Vekhir
Copy link
Contributor

Vekhir commented Feb 18, 2024

Hi,
when building dhall 1.42.1 on Arch Linux with GHC 9.8.1 and template-haskell 2.21.0.0, the following error occurs while building the tests:

tests/Dhall/Test/TH.hs:111:1: error: [GHC-58589]
    Illegal invisible type variable binder: @b0
    Suggested fix: Perhaps you intended to use TypeAbstractions
    |
111 | Dhall.TH.makeHaskellTypesWith (Dhall.TH.defaultGenerateOptions
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

The same error occurs 4 times (see Appendix). The error itself suggests to use TypeAbstractions to fix the issue.
The offending line is dhall/tests/Dhall/Test/TH.hs#L111, and the issue doesn't seem fixed on main.

template-haskell from 2.21 onwards supports Invisible binders in type declarations, see also the migration guide and GHC proposal #425.
dhall 1.42.1 advertises support for template-haskell 2.21 and GHC 9.8 - not sure what's going on there.

-- Vekhir

Appendix

[ 5 of 21] Compiling Dhall.Test.TH    ( tests/Dhall/Test/TH.hs, dist/build/tasty/tasty-tmp/Dhall/Test/TH.dyn_o )

tests/Dhall/Test/TH.hs:111:1: error: [GHC-58589]
    Illegal invisible type variable binder: @a0
    Suggested fix: Perhaps you intended to use TypeAbstractions
    |
111 | Dhall.TH.makeHaskellTypesWith (Dhall.TH.defaultGenerateOptions
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

tests/Dhall/Test/TH.hs:111:1: error: [GHC-58589]
    Illegal invisible type variable binder: @a1
    Suggested fix: Perhaps you intended to use TypeAbstractions
    |
111 | Dhall.TH.makeHaskellTypesWith (Dhall.TH.defaultGenerateOptions
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

tests/Dhall/Test/TH.hs:111:1: error: [GHC-58589]
    Illegal invisible type variable binder: @b0
    Suggested fix: Perhaps you intended to use TypeAbstractions
    |
111 | Dhall.TH.makeHaskellTypesWith (Dhall.TH.defaultGenerateOptions
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

tests/Dhall/Test/TH.hs:111:1: error: [GHC-58589]
    Illegal invisible type variable binder: @a0
    Suggested fix: Perhaps you intended to use TypeAbstractions
    |
111 | Dhall.TH.makeHaskellTypesWith (Dhall.TH.defaultGenerateOptions
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
@ysangkok
Copy link
Contributor

Does the code merged in

fix your issue?

@ysangkok
Copy link
Contributor

ysangkok commented Dec 16, 2024

Oh, seems that it doesn't , I am able to reproduce with

cabal get dhall
cd dhall-1.42.1
cabal test --enable-tests --allow-newer=special-values:bytestring -w ghc-9.8.4

@ysangkok
Copy link
Contributor

It's weird how it fails on GHC-9.8 when @TeofilC says in #2602 that they tested with GHC-9.10. I wonder if it's a bug fixed in GHC 9.10 somehow?

@TeofilC
Copy link
Contributor

TeofilC commented Dec 16, 2024

I think I might've missed these because I didn't pass --enable-tests, cabal-install didn't find a build plan and just skipped them. After enabling that flag I am also seeing these with 9.10

@TeofilC
Copy link
Contributor

TeofilC commented Dec 16, 2024

It looks like enabling TypeAbstractions doesn't fix this (at least with 9.10). I'll take a further look

@TeofilC
Copy link
Contributor

TeofilC commented Dec 16, 2024

For reference here's the error we get if we enable TypeAbstractions and the generated TH splice

Details

tests/Dhall/Test/TH.hs:114:1: error: [GHC-92337]
    • Invalid invisible type variable binder: @a0
      Either a standalone kind signature (SAKS)
      or a complete user-supplied kind (CUSK, legacy feature)
      is required to use invisible binders.
    • In the data type declaration for ‘MyHKSingle’
    Suggested fix: Add a standalone kind signature for ‘MyHKSingle’
    |
114 | Dhall.TH.makeHaskellTypesWith (Dhall.TH.defaultGenerateOptions
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...


tests/Dhall/Test/TH.hs:(114,1)-(122,5): Splicing declarations
    Dhall.TH.makeHaskellTypesWith
      (Dhall.TH.defaultGenerateOptions
         {Dhall.TH.constructorModifier = ("My" <>),
          Dhall.TH.fieldModifier = ("my" <>) . Data.Text.toTitle,
          Dhall.TH.generateFromDhallInstance = False,
          Dhall.TH.generateToDhallInstance = False})
      [SingleConstructor
         "MyHKSingle" "HKSingle" "./tests/th/HigherKindSingle.dhall",
       MultipleConstructors
         "MyHKUnion" "./tests/th/HigherKindUnion.dhall"]
  ======>
    data MyHKSingle @a1 @a0
      = MyHKSingle {myBam :: Dhall.Text, myBar :: (a1 a0), myFoo :: a0}
    data MyHKUnion @a0 @b0 = MyBar b0 | MyFoo a0

TeofilC added a commit to TeofilC/dhall-haskell that referenced this issue Dec 16, 2024
<dhall-lang#2542> allowed `dhall`
to compile with template-haskell-2.21 and GHC-9.8 by adapting to the
addition of a binder visibility field on type variables.

Previously all binders were taken to be required, but in GHC-9.8 the
possibility of invisible binders was introduced.

The above patch mistakenly set all binders generated by Dhall to be
invisible, rather than default value of required. This changes the
semantics of the code and broke some examples in the test suite.

This patch fixes this by correctly setting binders to be BndrReq.

Resolves dhall-lang#2567
TeofilC added a commit to TeofilC/dhall-haskell that referenced this issue Dec 16, 2024
dhall-lang#2542 allowed `dhall`
to compile with template-haskell-2.21 and GHC-9.8 by adapting to the
addition of a binder visibility field on type variables.

Previously all binders were taken to be required, but in GHC-9.8 the
possibility of invisible binders was introduced.

The above patch mistakenly set all binders generated by Dhall to be
invisible, rather than default value of required. This changes the
semantics of the code and broke some examples in the test suite.

This patch fixes this by correctly setting binders to be BndrReq.

Resolves dhall-lang#2567
@TeofilC
Copy link
Contributor

TeofilC commented Dec 16, 2024

#2622 should fix this by restoring the TH generated code to what it was before GHC-9.8

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 a pull request may close this issue.

3 participants