BinderDavid / mendel

Mutation Operators for Haskell Sourcecode
BSD 3-Clause "New" or "Revised" License
0 stars 2 forks source link

Support GHC 9.8 #2

Open BinderDavid opened 6 months ago

BinderDavid commented 6 months ago

Switch to ghc-lib 9.8 and add GHC 9.8 to the tested versions in CI.

kpadmasola commented 5 months ago

Hi @BinderDavid I'm interested in taking this up, but I am a beginner in Haskell and have done similar GHC upgrades and CI fixes in other projects. If you are OK with this, please let me know how I should proceed. Also, what is your preferred mode of communication: discord/twitter/email?

BinderDavid commented 5 months ago

Hi @kpadmasola,

Thanks for looking into picking up this issue. For this issue you would mainly have to check whether the project builds with GHC 9.8, and if not then you have to apply some compatibility fixes. After the code typechecks with GHC 9.8 we have to add a tested-with clause for 9.8 here: https://github.com/BinderDavid/mendel/blob/0d8fbff7e0cffdf448faf892c05269c20c6a81c8/mendel.cabal#L24 And then we have to regenerate the CI Skript using https://github.com/haskell-CI/haskell-ci

Communication w.r.t to the project preferably over GitHub, otherwise you can find my contact details on my website https://binderdavid.github.io, i.e. Mastodon and Email.

kpadmasola commented 5 months ago

Hi @BinderDavid With ghc-9.8.2, with ghc-lib-parser version 9.8.2.20240223, I am getting the following errors with cabal build

error log ``` src/Test/Mendel/Mutation.hs:38:51: error: [GHC-83865] • Couldn't match type ‘GHC.DoPmc -> GHC.Origin’ with ‘GHC.Origin’ Expected: GHC.XMG GHC.GhcPs (GHC.GenLocated GHC.SrcSpanAnnA (GHC.HsExpr GHC.GhcPs)) Actual: GHC.DoPmc -> GHC.Origin • In the first argument of ‘GHC.MG’, namely ‘GHC.Generated’ In the expression: GHC.MG GHC.Generated (GHC.L l (reverse body)) In an equation for ‘reverseClauses’: reverseClauses (GHC.MG _ (GHC.L l body)) = GHC.MG GHC.Generated (GHC.L l (reverse body)) | 38 | reverseClauses (GHC.MG _ (GHC.L l body)) = GHC.MG GHC.Generated (GHC.L l (reverse body)) | ^^^^^^^^^^^^^ [3 of 4] Compiling Test.Mendel.Parser ( src/Test/Mendel/Parser.hs, /Users/padmasol/fun/github/placidex/mendel/dist-newstyle/build/x86_64-osx/ghc-9.8.2/mendel-0.1.0.0/build/Test/Mendel/Parser.o, /Users/padmasol/fun/github/placidex/mendel/dist-newstyle/build/x86_64-osx/ghc-9.8.2/mendel-0.1.0.0/build/Test/Mendel/Parser.dyn_o ) src/Test/Mendel/Parser.hs:37:12: error: [GHC-83865] • Couldn't match expected type ‘GHC.DiagOpts’ with actual type ‘Maybe Int -> GHC.SDocContext -> GHC.DiagOpts’ • Probable cause: ‘GHC.DiagOpts’ is applied to too few arguments In the expression: GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext In an equation for ‘diagOpts’: diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | 37 | diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ src/Test/Mendel/Parser.hs:37:37: error: [GHC-83865] • Couldn't match expected type ‘GHC.Unit.Module.Warnings.WarningCategorySet’ with actual type ‘Bool’ • In the third argument of ‘GHC.DiagOpts’, namely ‘False’ In the expression: GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext In an equation for ‘diagOpts’: diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | 37 | diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | ^^^^^ src/Test/Mendel/Parser.hs:37:43: error: [GHC-83865] • Couldn't match expected type ‘GHC.Unit.Module.Warnings.WarningCategorySet’ with actual type ‘Bool’ • In the fourth argument of ‘GHC.DiagOpts’, namely ‘False’ In the expression: GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext In an equation for ‘diagOpts’: diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | 37 | diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | ^^^^^ src/Test/Mendel/Parser.hs:37:49: error: [GHC-83865] • Couldn't match expected type ‘Bool’ with actual type ‘Maybe a0’ • In the fifth argument of ‘GHC.DiagOpts’, namely ‘Nothing’ In the expression: GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext In an equation for ‘diagOpts’: diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | 37 | diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | ^^^^^^^ src/Test/Mendel/Parser.hs:37:57: error: [GHC-83865] • Couldn't match expected type ‘Bool’ with actual type ‘GHC.SDocContext’ • In the sixth argument of ‘GHC.DiagOpts’, namely ‘GHC.defaultSDocContext’ In the expression: GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext In an equation for ‘diagOpts’: diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | 37 | diagOpts = GHC.DiagOpts empty empty False False Nothing GHC.defaultSDocContext | ^^^^^^^^^^^^^^^^^^^^^^ ```

Should I try fixing the errors in Mutation.hs and Parser.hs? But if I do that, will it not break with older versions of GHC? Please suggest. Thanks.

BinderDavid commented 5 months ago

You can either choose the easy way or the hard way ;)

The easier way is to keep the dependency on ghc-lib-parser ==9.6.2.20230523, as it is, and only to update the CI so that the github actions also test whether we can compile the library with ghc version 9.8.

The hard way is to update the dependency to 9.8..... Then you also have to apply all the changes to the Haskell AST that were merged in the upstream library. But the library should still be compatible with earlier versions of GHC, because the ghc-lib-parser library is independent of GHC and can be compiled with multiple different GHC versions.

kpadmasola commented 5 months ago

@BinderDavid With ghc-lib-parser ==9.6.2.20230523, build constraints are violated.

cabal build error log ``` $ cabal build Resolving dependencies... Error: cabal: Could not resolve dependencies: [__0] trying: mendel-0.1.0.0 (user goal) [__1] next goal: ghc-lib-parser (dependency of mendel) [__1] rejecting: ghc-lib-parser-9.8.2.20240223 (conflict: mendel => ghc-lib-parser==9.6.2.20230523) [__1] skipping: ghc-lib-parser-9.8.1.20231121, ghc-lib-parser-9.8.1.20231009, ghc-lib-parser-9.6.5.20240423, ghc-lib-parser-9.6.4.20240109, ghc-lib-parser-9.6.3.20231121, ghc-lib-parser-9.6.3.20231014, ghc-lib-parser-9.6.2.20231121 (has the same characteristics that caused the previous version to fail: excluded by constraint '==9.6.2.20230523' from 'mendel') [__1] trying: ghc-lib-parser-9.6.2.20230523 [__2] next goal: base (dependency of mendel) [__2] rejecting: base-4.19.1.0/installed-654f (conflict: ghc-lib-parser => base>=4.16.1 && <4.19) [__2] skipping: base-4.19.1.0, base-4.19.0.0 (has the same characteristics that caused the previous version to fail: excluded by constraint '>=4.16.1 && <4.19' from 'ghc-lib-parser') [__2] rejecting: base-4.18.2.1, base-4.18.2.0, base-4.18.1.0, base-4.18.0.0, base-4.17.2.1, base-4.17.2.0, base-4.17.1.0, base-4.17.0.0, base-4.16.4.0, base-4.16.3.0, base-4.16.2.0, base-4.16.1.0, base-4.16.0.0, base-4.15.1.0, base-4.15.0.0, base-4.14.3.0, base-4.14.2.0, base-4.14.1.0, base-4.14.0.0, base-4.13.0.0, base-4.12.0.0, base-4.11.1.0, base-4.11.0.0, base-4.10.1.0, base-4.10.0.0, base-4.9.1.0, base-4.9.0.0, base-4.8.2.0, base-4.8.1.0, base-4.8.0.0, base-4.7.0.2, base-4.7.0.1, base-4.7.0.0, base-4.6.0.1, base-4.6.0.0, base-4.5.1.0, base-4.5.0.0, base-4.4.1.0, base-4.4.0.0, base-4.3.1.0, base-4.3.0.0, base-4.2.0.2, base-4.2.0.1, base-4.2.0.0, base-4.1.0.0, base-4.0.0.0, base-3.0.3.2, base-3.0.3.1 (constraint from non-upgradeable package requires installed instance) [__2] fail (backjumping, conflict set: base, ghc-lib-parser, mendel) After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: base, ghc-lib-parser, mendel ```

So I guess it is the hard way, then?

kpadmasola commented 5 months ago

@BinderDavid probably a dumb question, but how do I find all the changes to the Haskell AST that were merged in the upstream library ? I looked at this repo: https://github.com/digital-asset/ghc-lib, but it was not obvious to me as there were no release tags or branches corresponding to the version of ghc-lib-parser

kpadmasola commented 5 months ago

@BinderDavid the changes between 9.6.2.20230523 and 9.8.2.20240223 versions seem to be in https://github.com/digital-asset/ghc-lib/compare/cb226de..429b5f6, but I was not able to identify the changes needed to fix the build errors with version 9.8.2.20240223.

BinderDavid commented 5 months ago

Sorry for being a bit unresponsive :( I asked in the GHC Matrix channel if there is some changelog which records the changes to the AST, but they told me there isn't one. So we can currently only rely on what git tells us. I had hoped that you don't run into those issues, sorry :/ I will try to do some investigation tomorrow.

kpadmasola commented 4 months ago

@BinderDavid Sure, no problem. Please let me know once you identify a suitable approach for making some progress here. Thanks.