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

Fix GHC 9.2 build #1514

Merged
merged 1 commit into from
Jan 25, 2022
Merged

Fix GHC 9.2 build #1514

merged 1 commit into from
Jan 25, 2022

Conversation

guibou
Copy link
Contributor

@guibou guibou commented Jan 24, 2022

Close #1513.

GHC 9.2 needs explicit kind signature here, I don't really understand
why.

This kind signature is correct and not too restritive, because HasLink
is technically defined class HasLink endpoint which means that it is
infered as k -> Constraint. In the instance signature, we have
HasLink ((arr :: a -> b) :> sub), so here the k is the same kind as
the one of :> which is not polykinded.

Note: build tested with GHC 9.2 and the following workflow:

$ nix-shell ./ --argstr compiler 'ghc921' --arg pkgs 'import <nixpkgs> {}' -A servant

[nix-shell:~/srcs/servant]$ nix-shell -p cabal-install

[nix-shell:~/srcs/servant]$ cabal build servant
Up to date

I had to bump a few bounds:

diff --git a/cabal.project b/cabal.project
index ac4a4e3b..e2573fa9 100644
--- a/cabal.project
+++ b/cabal.project
@@ -57,7 +57,7 @@ constraints:
   foundation >=0.0.14,
   memory <0.14.12 || >0.14.12
 
-constraints: base-compat ^>=0.11
+constraints: base-compat ^>=0.12
 constraints: semigroups ^>=0.19
 
 -- allow-newer: sqlite-simple-0.4.16.0:semigroups
@@ -74,3 +74,5 @@ allow-newer: servant-js:servant
 
 -- ghc 9
 allow-newer: tdigest:base
+
+allow-newer: *
diff --git a/servant/servant.cabal b/servant/servant.cabal
index f5f973bb..14193e18 100644
--- a/servant/servant.cabal
+++ b/servant/servant.cabal
@@ -80,7 +80,7 @@ library
   --
   -- note: mtl lower bound is so low because of GHC-7.8
   build-depends:
-      base                   >= 4.9      && < 4.16
+      base                   >= 4.9      && < 4.17
     , bytestring             >= 0.10.8.1 && < 0.12
     , constraints            >= 0.2
     , mtl                    >= 2.2.2    && < 2.3
@@ -98,7 +98,7 @@ library
   -- Other dependencies: Lower bound around what is in the latest Stackage LTS.
   -- Here can be exceptions if we really need features from the newer versions.
   build-depends:
-      base-compat            >= 0.10.5   && < 0.12
+      base-compat            >= 0.12   && < 0.13
     , aeson                  >= 1.4.1.0  && < 3
     , attoparsec             >= 0.13.2.2 && < 0.15
     , bifunctors             >= 5.5.3    && < 5.6

(I have no idea what I'm doing there).

This patchs works in production and should be relatively safe considering that it only changes error messages, it should have no impact on running programs.

Close haskell-servant#1513.

GHC 9.2 needs explicit kind signature here, I don't really understand
why.

This kind signature is correct and not too restritive, because `HasLink`
is technically defined `class HasLink endpoint` which means that it is
infered as `k -> Constraint`. In the instance signature, we have
`HasLink ((arr :: a -> b) :> sub)`, so here the `k` is the same kind as
the one of `:>` which is not polykinded.
@guibou
Copy link
Contributor Author

guibou commented Jan 24, 2022

/cc @teto because you care as much as me about GHC 9.2 support ;)

Copy link
Contributor

@gdeest gdeest left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

Note that your change was already part of #1482 ; we will probably have to wait for the rest of the ecosystem to support 9.2 before we can enable CI.

@gdeest gdeest merged commit 7a770b5 into haskell-servant:master Jan 25, 2022
@guibou
Copy link
Contributor Author

guibou commented Jan 25, 2022

Thank you for merging, and sorry for the noise, I did not saw the initial MR.

@guibou guibou deleted the fix_ghc92_build branch January 25, 2022 11:09
k0001 added a commit to k0001/servant that referenced this pull request Feb 4, 2022
The issue is similar to the one in haskell-servant#1513:

```
src/Servant/Server/Internal.hs:824:10: error:
    • Uninferrable type variable k0 in
      type family equation right-hand side: (TypeError ...)
    • In the type instance declaration for ‘ServerT’
      In the instance declaration for
        ‘HasServer ((arr :: a -> b) :> sub) context’
    |
824 |     type ServerT (arr :> sub) _ = TypeError (PartialApplication HasServer arr)
    |
```

This fix is similar to the one in haskell-servant#1514.
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.

Type error with GHC 9.2
2 participants