Conversation
| - # If upgrading the Haskell image, also upgrade it in the lint job below | ||
| os: "ubuntu-latest" | ||
| image: "haskell:8.10.7-stretch@sha256:100f8fb7d7d8d64adb5e106fe8136b8d4cbdc03aeb2cbd145a7597d74b69bafb" | ||
| image: "haskell:9.2.2-buster@sha256:c2f489a95be8dd0b253da6980420a6e9c02e81c2d14838ca774f86f5b5db91f4" |
There was a problem hiding this comment.
buster (Debian 10) is the next Debian release after stretch. There is no stretch image which includes GHC 9.2.2, probably because stretch will stop receiving security updates next month (June 2022).
There was a problem hiding this comment.
Looks like this would mean bumping our glibc dependency from 2.24 to 2.28.
Should we make a Discourse post asking if people would object to that? Seems like we consistently stir up trouble whenever this changes.
There was a problem hiding this comment.
Yes, good point. This certainly isn’t ideal. Maybe we should just take a basic Debian stretch image and install the Haskell tools ourselves? My inclination is to avoid bumping this if we can manage it.
| | $(GitRev.gitDirty) = " DIRTY" | ||
| | otherwise = "" | ||
| dirty = | ||
| if $(GitRev.gitDirty) |
There was a problem hiding this comment.
Before this change, GHC would complain that the otherwise case was redundant if GitRev.gitDirty evaluated to True.
| deriving (Show, Eq, Ord, Foldable, Functor, Traversable) | ||
|
|
||
| $(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''NameSource) | ||
| $(deriveJSON (defaultOptions { sumEncoding = ObjectWithSingleField }) ''ExportSource) |
There was a problem hiding this comment.
This (and a few other JSON instance rearrangements) were necessary because any instances defined below a TH deriveJSON call like this one won't be visible to that call, so if a data type A references another data type B in its definition, then the deriveJSON for B has to come before the one for A.
| properName n = ProperName (N.coerceProperName <$> n) | ||
|
|
||
| getProperName :: forall a. ProperName -> Name (N.ProperName a) | ||
| getProperName pn = _getProperName pn -- eta expansion needed here due to simplified subsumption |
There was a problem hiding this comment.
Without this change, you get an error like:
src\Language\PureScript\CST\Utils.hs:47:17: error:
* Couldn't match type: forall (a1 :: N.ProperNameType).
Name (N.ProperName a1)
with: Name (N.ProperName a)
Expected: ProperName -> Name (N.ProperName a)
Actual: ProperName
-> forall (a :: N.ProperNameType). Name (N.ProperName a)
* In the expression: _getProperName
In an equation for `getProperName': getProperName = _getProperName
* Relevant bindings include
getProperName :: ProperName -> Name (N.ProperName a)
(bound at src\Language\PureScript\CST\Utils.hs:47:1)
|
47 | getProperName = _getProperName
| ^^^^^^^^^^^^^^
| constructorTypeToJSON SumType = toJSON "SumType" | ||
|
|
||
| infixr 8 .= | ||
| (.=) :: ToJSON a => String -> a -> Pair |
There was a problem hiding this comment.
Almost everything in this module is due to aeson-2 changes, specifically the left hand side of .= must now be a Key rather than a Text. I thought it might be easier to define our own version of .= so that we don't have to convert the key to a different type each time we call it.
| go jss | not (any isReturn jss) = jss | ||
| | otherwise = let (body, ret : _) = break isReturn jss in body ++ [ret] | ||
| go jss = | ||
| case break isReturn jss of |
There was a problem hiding this comment.
This change was necessitated by the fact that -Wincomplete-uni-patterns was added to -Wall at some point between 8.10.7 and 9.2.2; the let (body, ret : _) = ... is an incomplete pattern because it does not account for what happens if the second element of the tuple is an empty list. Thankfully we can avoid it (as well as an unnecessary traversal of the list) by rewriting the function to use break instead.
| let (x, a : y) = splitAt i l | ||
| in x ++ [t a] ++ y | ||
| updateAtFirstOrPrepend predicate update def xs = | ||
| case break predicate xs of |
There was a problem hiding this comment.
Another case where using break solves both a -Wincomplete-uni-patterns warning and also removes an unnecessary traversal of the list at the same time. I thought I'd take the opportunity to use clearer argument names here too.
| let ImportRecord (Qualified (Just mnNew) _) mnOrig _ _ = head byOrig | ||
| in return (mnNew, mnOrig) | ||
| case head byOrig of | ||
| ImportRecord (Qualified (Just mnNew) _) mnOrig _ _ -> |
There was a problem hiding this comment.
Another -Wincomplete-uni-patterns warning
| -- | Check that a newtype has just one data constructor with just one field, or | ||
| -- throw an error. If the newtype is valid, this function returns the single | ||
| -- data constructor declaration and the single field, as a 'proof' that the | ||
| -- newtype was indeed a valid newtype. |
There was a problem hiding this comment.
Returning the decl and the field here means that we avoid an unsafe pattern match in Sugar/TypeClasses/Deriving.
- Allow -Wincomplete-uni-patterns warnings in tests - Compare the graph fixture as a JSON Value so that the ordering doesn't matter - define and use `tails1` in TypeChecker.Entailment to make the validity of the non-emptiness assumption more obvious - Bump to stack 2.7.5 in CI (to match the 9.2.2 Docker image)
| dicts | ||
| -- process instances in a chain in index order | ||
| let found = for (init $ tails chain) $ \(tcd:tl) -> | ||
| let found = for (tails1 chain) $ \(tcd :| tl) -> |
There was a problem hiding this comment.
Another -Wincomplete-uni-patterns warning. This was safe before, but now the safety is tracked in the types.
| Right res -> | ||
| let textRes = Text.decodeUtf8 $ ByteString.toStrict $ Json.encode res | ||
| in graphFixture `shouldBe` textRes | ||
| res `shouldBe` graphFixture |
There was a problem hiding this comment.
This change means that we don't have to update the fixture if the order of fields changes, and we don't get errors if the fields end up in different orders due to different build configurations. Updating aeson seems to have caused the fields in the result to end up in a different order.
There was a problem hiding this comment.
Also, you're supposed to put the expected value second. The error message describes the 'expected' vs 'actual' value, so the error can be misleading if you put the expected value first; this is why I've flipped them around.
|
Seems like CI time for this branch is hovering around 14-15 mins, which might be slightly faster than it is currently (usually 15-18 mins from the looks of things), but the variance seems quite high so it's hard to tell. |
|
I've created #4336, which covers a part of this (the new warnings) that can be merged now. As for the rest, I am inclined to wait until the upstream dependencies (weeder and protolude) are ready, so I think I'll close this for now. |
|
Looks like Weeder got updated to |
|
So now that protolude has been updated I think the only remaining task is to figure out why cabal thinks PureScript depends on the GHC API. If you try building PureScript with cabal instead of stack, it tries to compile the GHC API and fails. I think I might write something up and ask on the Cabal issue tracker or something, because this is quite strange to me. |
What package, exactly? |
|
|
|
Can't reproduce this on my side. I just successfully compiled the code from this PR. |
|
Interesting 🤔 |
This PR updates us to GHC 9.2.2. Most of the updates are fairly straightforward; I will explain why I've made them as inline review comments.
The main reasons I think we might want to do this are:
Reasons not to merge this yet:
protolude-0.3.1which is tagged but not yet uploaded to Hackage so for now I'm using a git reference instack.yaml; this means that people would probably struggle to compile the PureScript compiler with cabal if we made a release with these changes. We should probably either drop theprotoludedependency or wait for 0.3.1 to be uploaded to Hackage.Weeder does not yet compile on GHC 9.2Weeder 2.4.0, which targets GHC 9.2, has just been released