-
Notifications
You must be signed in to change notification settings - Fork 126
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 building with GHC 9.2 #1349
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RyanGlScott
commented
May 2, 2022
yav
approved these changes
May 3, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
This contains a variety of changes needed to make Cryptol compile with GHC 9.2: * In GHC 9.2, enabling `UndecidableInstances` no longer implies enabling `FlexibleContexts` (see [here](https://gitlab.haskell.org/ghc/ghc/-/wikis/migration/9.2?version_id=7e2ce63ba042c1934654c4316dc02028d8d3dd31#undecidableinstances-no-longer-implies-flexiblecontexts-in-instance-declarations)). As a result, I had to enable `FlexibleContexts` in `Cryptol.ModuleSystem.Name`. * The `argo` submodule was bumped to bring in the changes from GaloisInc/argo#191, which allows it to build with GHC 9.2. * The upper version bounds on `base`, `bytestring`, `lens`, `base-compat`, and `sbv` were raised to allow building them with GHC 9.2.
GHC 9.2 now includes `-Woperator-whitespace-ext-conflict` as a part of `-Wall`. Thankfully, these warnings are simple to resolve: just put extra whitespace after the affected uses of `$`.
GHC 9.2 adds `-Wnoncanonical-monad-instances` and `-Wnoncanonical-monoid-instances` to `-Wall`, which warn whenever one has explicit implementations of `return` or `mappend` that aren't simply `return = pure` or `mappend = (<>)`. This patch makes sure that all `Monad` and `Monoid` instances in Cryptol adhere to these conventions.
GHC 9.2 has a more aggressive pattern-match coverage checker than in previous versions, which reveals that the `detailedPrompt` case of `mkPrompt` is unreachable. This is technically true, as `detailedPrompt = False`, but it would be nice if we didn't get a warning just for keeping this code around. This simplest solution is to just change `detailedPrompt` to be `id False`, which defeats the coverage checker. An alternative would be to use `GHC.Exts`' newly added `considerAccessible` function (see https://gitlab.haskell.org/ghc/ghc/-/merge_requests/5100), but this would require CPP.
GHC 9.2 now includes `-Wincomplete-uni-patterns` as a part of `-Wall`. As a result, building Cryptol with GHC 9.2 uncovers some previously undetected warnings. Some warnings can be fixed by rewriting the code slightly. For example, changing a use of `Data.List.groupBy` to `Data.List.NonEmpty.groupBy` avoids the need for an incomplete match on `(_ : _)` on the value that `groupBy` returns. (Since `Data.List.NonEmpty` was added to `base` in `4.9`, this also requires bumping the lower version bounds on `base` slightly.) Other warnings were fixed by explicitly adding fall-through `error` cases. The resulting code is no less partial than before, but it avoids warnings and should provide a more specific error in the event that the fall-through cases are reached. Yet another class of warnings are those caused by the use of irrefutable patterns, such as the definition of `ar1 ~[x] = x` in `Cryptol.TypeCheck.TypePat`. It's rather unfortunate that `-Wincomplete-uni-patterns` warns about these (see https://gitlab.haskell.org/ghc/ghc/-/issues/14800), as the only way to avoid the warning would be to rewrite these functions to use refutable patterns, thereby changing their strictness properties. I've decided to simply disable `-Wincomplete-uni-patterns` in each module that uses irrefutable patterns to avoid this issue. I've written also written a Note explaining the reasoning and referenced it in the affected modules.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This contains a variety of changes needed to make Cryptol compile with GHC 9.2:
UndecidableInstances
no longer implies enablingFlexibleContexts
(see here). As a result, I had to enableFlexibleContexts
inCryptol.ModuleSystem.Name
.argo
submodule was bumped to bring in the changes from Allow building with GHC 9.2 argo#191, which allows it to build with GHC 9.2.base
,bytestring
,lens
,base-compat
, andsbv
were raised to allow building them with GHC 9.2.In addition, I fixed a variety of warnings that resulted from GHC 9.2 adding new things to
-Wall
, including-Woperator-whitespace-ext-confict
,-Wnoncanonical-{monad,monoid}-instances
, and-Wincomplete-uni-patterns
.-Wincomplete-uni-patterns
in particular was the trickiest to adapt to, and I have written aNote [-Wincomplete-uni-patterns and irrefutable patterns]
describing the approach I took for irrefutable patterns.