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

Support GHC 9.2 #1717

Merged
merged 10 commits into from
Mar 16, 2023
Merged

Support GHC 9.2 #1717

merged 10 commits into from
Mar 16, 2023

Conversation

RyanGlScott
Copy link
Contributor

@RyanGlScott RyanGlScott commented Aug 1, 2022

This contains a variety of minor changes needed to make saw and its supporting libraries compile with GHC 9.2:

  • One place in heapster-saw matches on a GADT using a let binding, which no longer typechecks in GHC 9.2. While somewhat mysterious, using let bindings to match on GADTs is fragile anyway, so I opted to simply replace this with a monadic do match, which does not exhibit the same fragility.
  • GHC now includes -Wincomplete-uni-patterns in -Wall as of 9.2, so much of this patch is dedicated to silencing these sorts of warnings, usually by adding explicit fall-through cases for partial pattern matches.
  • GHC now inclues -Wnoncanonical-monad-instances in -Wall as of 9.2, so I had to refactor some Applicative/Monad instances to fix these warnings.
  • GHC 9.2 now defines readBin in Numeric, which clashes with a function of the same name in SAWScript.Lexer. Using explicit imports avoids this.
  • GHC's pattern-match coverage checker is smarter in 9.2 (see here), so I had to use EmptyCase to silence some of the new -Wincomplete-patterns warnings that were uncovered in heapster-saw.

@RyanGlScott
Copy link
Contributor Author

At long last, I believe this is finally ready. A special thanks to @eddywestbrook for contributing patches to fix the numerous -Wincomplete-uni-patterns warnings in heapster-saw that were uncovered by GHC 9.2 adding that warning to -Wall. I also tried to clean up the uses of head and tail to replace them with more specific versions of these functions that give slightly more specific errors if they fail—let me know if you are OK with this.

I've also added @chameco and @kquick as reviewers for everything else in this patch. It touches a lot of different parts of the code, but it's mostly a collection of small changes. Let me know if anything looks especially surprising!

Copy link
Contributor

@eddywestbrook eddywestbrook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After going through these changes in a relatively high level of detail, the changes overall look good and make sense, though I haven't been able to look at absolutely everything. At a high level, the changes mostly are to address the new requirement that pattern-matching always satisfies coverage, and raise explicit errors when an unexpected pattern is matched.

@RyanGlScott RyanGlScott force-pushed the ghc-9.2 branch 4 times, most recently from 9e96dab to 8d7c9bc Compare March 15, 2023 20:22
Copy link
Member

@kquick kquick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the trailing whitespace and corresponding removals are unfortunate, but for the most part the changes here are pretty isomorphic to the original implicit behavior, so I don't see anything concerning.

RyanGlScott and others added 10 commits March 16, 2023 14:55
This contains a variety of minor changes needed to make `saw` and its
supporting libraries compile with GHC 9.2:

* One place in `heapster-saw` matches on a GADT using a `let` binding, which no
  longer typechecks in GHC 9.2. While somewhat mysterious, using `let` bindings
  to match on GADTs is fragile anyway, so I opted to simply replace this with a
  monadic `do` match, which does not exhibit the same fragility.
* GHC now includes `-Wincomplete-uni-patterns` in `-Wall` as of 9.2, so much
  of this patch is dedicated to silencing these sorts of warnings, usually by
  adding explicit fall-through cases for partial pattern matches.
* GHC now inclues `-Wnoncanonical-monad-instances` in `-Wall` as of 9.2, so I
  had to refactor some `Applicative`/`Monad` instances to fix these warnings.
* GHC 9.2 now defines `readBin` in `Numeric`, which clashes with a function of
  the same name in `SAWScript.Lexer`. Using explicit imports avoids this.
* GHC's pattern-match coverage checker is smarter in 9.2 (see
  [here](https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.2?version_id=63085dd8a5b56370571bda428848e7098765f7f8#improved-pattern-match-coverage-checker)),
  so I had to use `EmptyCase` to silence some of the new
  `-Wincomplete-patterns` warnings that were uncovered in `heapster-saw`.
This version does not need to install `cabal-plan`, which avoids build plan
issues.
Not only is pinning the `cabal` version good practice, but `cabal` 3.8.1.0 in
particular likely contains a bugfix needed to make `cabal list-bin` work as
expected.
@RyanGlScott RyanGlScott merged commit dbf2e31 into master Mar 16, 2023
@RyanGlScott RyanGlScott deleted the ghc-9.2 branch March 16, 2023 19:53
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 this pull request may close these issues.

3 participants