stylish-haskell icon indicating copy to clipboard operation
stylish-haskell copied to clipboard

Doesn't compile with GHC 9.2.3

Open Mikolaj opened this issue 2 years ago • 5 comments

Fails with

~$ cabal install stylish-haskell
Resolving dependencies...
Build profile: -w ghc-9.2.3 -O1
In order, the following will be built (use -v for more details):
 - stylish-haskell-0.14.2.0 (lib) (requires build)
 - stylish-haskell-0.14.2.0 (exe:stylish-haskell) (requires build)
Starting     stylish-haskell-0.14.2.0 (lib)
Building     stylish-haskell-0.14.2.0 (lib)

Failed to build stylish-haskell-0.14.2.0.
Build log (
/home/mikolaj/.cabal/logs/ghc-9.2.3/stylish-haskell-0.14.2.0-b54ac8d49070c15bc96bb1ea4cb38bcc1ab66990033c8c3a3f41c50a1f1f94c5.log
):
Configuring library for stylish-haskell-0.14.2.0..
Preprocessing library for stylish-haskell-0.14.2.0..
Building library for stylish-haskell-0.14.2.0..
[ 1 of 26] Compiling Language.Haskell.Stylish.Block ( lib/Language/Haskell/Stylish/Block.hs, dist/build/Language/Haskell/Stylish/Block.o, dist/build/Language/Haskell/Stylish/Block.dyn_o )
[ 2 of 26] Compiling Language.Haskell.Stylish.Config.Internal ( lib/Language/Haskell/Stylish/Config/Internal.hs, dist/build/Language/Haskell/Stylish/Config/Internal.o, dist/build/Language/Haskell/Stylish/Config/Internal.dyn_o )
[ 3 of 26] Compiling Language.Haskell.Stylish.Editor ( lib/Language/Haskell/Stylish/Editor.hs, dist/build/Language/Haskell/Stylish/Editor.o, dist/build/Language/Haskell/Stylish/Editor.dyn_o )
[ 4 of 26] Compiling Language.Haskell.Stylish.GHC ( lib/Language/Haskell/Stylish/GHC.hs, dist/build/Language/Haskell/Stylish/GHC.o, dist/build/Language/Haskell/Stylish/GHC.dyn_o )

lib/Language/Haskell/Stylish/GHC.hs:71:32: error:
    • Couldn't match expected type ‘GHC.Settings’
                  with actual type ‘ghc-lib-parser-9.2.3.20220527:GHC.Settings.Settings’
      NB: ‘GHC.Settings’
            is defined in ‘GHC.Settings’ in package ‘ghc-9.2.3’
          ‘ghc-lib-parser-9.2.3.20220527:GHC.Settings.Settings’
            is defined in ‘GHC.Settings’
                in package ‘ghc-lib-parser-9.2.3.20220527’
    • In the first argument of ‘defaultDynFlags’, namely
        ‘GHCEx.fakeSettings’
      In the expression:
        defaultDynFlags GHCEx.fakeSettings GHCEx.fakeLlvmConfig
      In an equation for ‘baseDynFlags’:
          baseDynFlags
            = defaultDynFlags GHCEx.fakeSettings GHCEx.fakeLlvmConfig
   |
71 | baseDynFlags = defaultDynFlags GHCEx.fakeSettings GHCEx.fakeLlvmConfig
   |                                ^^^^^^^^^^^^^^^^^^

lib/Language/Haskell/Stylish/GHC.hs:71:51: error:
    • Couldn't match expected type ‘GHC.LlvmConfig’
                  with actual type ‘ghc-lib-parser-9.2.3.20220527:GHC.Driver.Session.LlvmConfig’
      NB: ‘GHC.LlvmConfig’
            is defined in ‘GHC.Driver.Session’ in package ‘ghc-9.2.3’
          ‘ghc-lib-parser-9.2.3.20220527:GHC.Driver.Session.LlvmConfig’
            is defined in ‘GHC.Driver.Session’
                in package ‘ghc-lib-parser-9.2.3.20220527’
    • In the second argument of ‘defaultDynFlags’, namely
        ‘GHCEx.fakeLlvmConfig’
      In the expression:
        defaultDynFlags GHCEx.fakeSettings GHCEx.fakeLlvmConfig
      In an equation for ‘baseDynFlags’:
          baseDynFlags
            = defaultDynFlags GHCEx.fakeSettings GHCEx.fakeLlvmConfig
   |
71 | baseDynFlags = defaultDynFlags GHCEx.fakeSettings GHCEx.fakeLlvmConfig
   |                                                   ^^^^^^^^^^^^^^^^^^^^
Error: cabal: Failed to build stylish-haskell-0.14.2.0 (which is required by
exe:stylish-haskell from stylish-haskell-0.14.2.0). See the build log above
for details.

Mikolaj avatar Jun 09 '22 20:06 Mikolaj

I think that is blocking the haskell-language-server 923 release, (at least when I tried to package the plugin-enabled version in nix).

teto avatar Jul 08 '22 15:07 teto

Enabling cabal flag ghc-lib for package stylish-haskell should help. Example:

cabal install --constraint "stylish-haskell +ghc-lib" stylish-haskell

kokobd avatar Jul 12 '22 05:07 kokobd

Confirmed. So, I guess, the flag should be conditionally enabled in .cabal? Or marked as not manual, so that cabal can try it out (I haven't tested that variant)?

Mikolaj avatar Jul 12 '22 05:07 Mikolaj

Actually, the latter won't work, because it's a compilation failure, not a build plan failure.

Mikolaj avatar Jul 12 '22 05:07 Mikolaj

Same issue with ghc 9.2.2 as well

Enabling cabal flag ghc-lib for package stylish-haskell should help. Example:

cabal install --constraint "stylish-haskell +ghc-lib" stylish-haskell

This works though

sloorush avatar Sep 07 '22 16:09 sloorush

This error also occurs when stylish-haskell is used as a haskell.nix shell.tool: https://input-output-hk.github.io/haskell.nix/tutorials/getting-started-flakes.html#scaffolding

example: https://github.com/peterbecich/halogen-chess/blob/cc1f5f6328d4571e1b0331ab58c88b6596015cff/flake.nix#L201-L210

A.f.a.i.k. haskell.nix builds these tools directly from Hackage, I don't know where the solution above cabal install --constraint "stylish-haskell +ghc-lib" stylish-haskell would be applied. I don't know if the Nix configuration here is used for shell.tool: https://github.com/haskell/stylish-haskell/blob/main/default.nix


The workaround is to build stylish-haskell separately from the other shell tools with GHC 9.0: https://github.com/peterbecich/halogen-chess/blob/3e0902b1509b50f54ebdf7b3160e1ccad53961ba/flake.nix#L189-L190

peterbecich avatar Nov 20 '22 22:11 peterbecich

Same problem with GHC 9.2.5 and stylish-haskell-0.14.3.0.

andreasabel avatar Dec 27 '22 22:12 andreasabel

Can this be closed? It appears the GHC 9.2 build and tests succeed: https://github.com/haskell/stylish-haskell/actions/runs/4339790807/jobs/7577708631

peterbecich avatar Mar 06 '23 05:03 peterbecich

Yes, it works great, thank you.

Mikolaj avatar Mar 06 '23 06:03 Mikolaj