Skip to content

Incompatibility with -fauto-built ghc-lib-parser-ex #1076

@Vekhir

Description

@Vekhir

Problem

On Arch, the ghc-lib-parser-ex package is built using the -fauto flag. This makes ghc-lib-parser-ex use GHC directly instead of going through ghc-lib-parser.
However, this leads to many errors of this kind:

[ 5 of 39] Compiling HIndent.Fixity   ( src/HIndent/Fixity.hs, dist/build/HIndent/Fixity.dyn_o )

src/HIndent/Fixity.hs:19:12: error:
    • Couldn't match type ‘ghc-9.4.8:GHC.Types.Fixity.Fixity’
                     with ‘Fixity’
      Expected: [(String, Fixity)]
        Actual: [(String, ghc-9.4.8:GHC.Types.Fixity.Fixity)]
      NB: ‘Fixity’
            is defined in ‘GHC.Types.Fixity’
                in package ‘ghc-lib-parser-9.4.8.20231111’
          ‘ghc-9.4.8:GHC.Types.Fixity.Fixity’
            is defined in ‘GHC.Types.Fixity’ in package ‘ghc-9.4.8’
    • In the first argument of ‘(<>)’, namely ‘baseFixities’
      In the expression: baseFixities <> lensFixities
      In an equation for ‘fixities’:
          fixities = baseFixities <> lensFixities
   |
19 | fixities = baseFixities <> lensFixities
   |            ^^^^^^^^^^^^

because the Fixity in GHC is different from the Fixity in ghc-lib-parser.

The only other affected file is src/HIndent/LanguageExtension/Conversion.hs:

[ 12 of 113] Compiling HIndent.LanguageExtension.Conversion ( src/HIndent/LanguageExtension/Conversion.hs, dist/build/HIndent/LanguageExtension/Conversion.dyn_o )

src/HIndent/LanguageExtension/Conversion.hs:52:20: error:
    • Couldn't match type ‘ghc-boot-th-9.4.8:GHC.LanguageExtensions.Type.Extension’
                     with ‘GLP.Extension’
      Expected: String -> Maybe GLP.Extension
        Actual: String
                -> Maybe ghc-boot-th-9.4.8:GHC.LanguageExtensions.Type.Extension
      NB: ‘GLP.Extension’
            is defined in ‘GHC.LanguageExtensions.Type’
                in package ‘ghc-lib-parser-9.4.8.20231111’
          ‘ghc-boot-th-9.4.8:GHC.LanguageExtensions.Type.Extension’
            is defined in ‘GHC.LanguageExtensions.Type’
                in package ‘ghc-boot-th-9.4.8’
    • In the first argument of ‘(.)’, namely ‘GLP.readExtension’
      In the expression: GLP.readExtension . show
      In an equation for ‘convertExtension’:
          convertExtension = GLP.readExtension . show
   |
52 | convertExtension = GLP.readExtension . show
   |                    ^^^^^^^^^^^^^^^^^

for a similar reason.

This issue affects all versions since 6.0.0 (Arch is still on 5.3.4), thus preventing the upgrade. Since hindent 5.3.4 doesn't support GHC 9.6, this blocks upgrading GHC itself.

  • I checked the issue tracker for existing issues about this problem.
  • I'm using the latest version of hindent.

Workaround

To work around this issue, we can basically replace ghc-lib-parser with ghc and ghc-boot. The result is a ton of CPP errors, because there is version checking based on ghc-lib-parser. However, this can be mitigated by replacing those checks with checks on GHC:

sed -e 's/"ghc-lib-parser" //' -e 's/ghc_lib_parser/ghc/' -i src/HIndent/Pretty.hs
sed -e 's/"ghc-lib-parser" //' -e 's/ghc_lib_parser/ghc/' -i src/HIndent/Pretty/NodeComments.hs
sed -e 's/"ghc-lib-parser" //' -e 's/ghc_lib_parser/ghc/' -i src/HIndent/Pretty/Types.hs
sed -e 's/"ghc-lib-parser" //' -e 's/ghc_lib_parser/ghc/' -i src/HIndent/Parse.hs
sed -e 's/"ghc-lib-parser" //' -e 's/ghc_lib_parser/ghc/' -i src/HIndent/ModulePreprocessing.hs

This is of course quite hacky and I'd hope for a better solution, but it works as expected since ghc-lib-parser and ghc on the same version are intentionally compatible.

Just wanted to let you know. Maybe there is something else that can be done.

System information

OS: Arch Linux
Kernel: Linux 6.15.9-arch1-1
GHC: 9.4.8-1
ghc-lib-parser: 9.4.8.20231111
ghc-lib-parser-ex: 9.4.0.0
hindent: 6.0.0, 6.1.0, 6.2.1

Appendix

hindent-6.2.1-226-x86_64-build.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions