Skip to content

Commit

Permalink
Compatibility with GHC-9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ysangkok committed Jun 19, 2023
1 parent 0babbed commit e9d283a
Show file tree
Hide file tree
Showing 20 changed files with 57 additions and 41 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
cabal: ["3.6"]
cabal: ["3.10"]
ghc:
- "8.6.5"
- "8.8.4"
- "8.10.7"
- "9.0.2"
- "9.2.7"
- "9.4.4"
- "9.2.8"
- "9.4.5"
- "9.6.2"

steps:
- uses: actions/checkout@v2

- uses: haskell/actions/setup@v1
- uses: haskell/actions/setup@v2
id: setup-haskell-cabal
name: Setup Haskell
with:
Expand All @@ -35,7 +36,7 @@ jobs:
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
cabal freeze
- uses: actions/cache@v2.1.3
- uses: actions/cache/restore@v3
name: Cache ~/.cabal/store and dist-newstyle
with:
path: |
Expand All @@ -45,9 +46,9 @@ jobs:
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-
- name: Configure
- name: Install doctest
run: |
cabal install --ignore-project -j2 doctest --constraint='doctest ^>=0.20'
cabal install --ignore-project -j2 doctest --constraint='doctest ^>=0.21'
- name: Build
run: |
Expand All @@ -62,7 +63,7 @@ jobs:
# Necessary for doctest to be found in $PATH
export PATH="$HOME/.cabal/bin:$PATH"
DOCTEST="cabal repl --with-ghc=doctest --ghc-options=-w"
DOCTEST="cabal repl --with-ghc=doctest"
(cd servant && eval $DOCTEST)
(cd servant-client && eval $DOCTEST)
(cd servant-client-core && eval $DOCTEST)
Expand Down Expand Up @@ -114,7 +115,7 @@ jobs:
runs-on: "ubuntu-latest"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
Expand All @@ -129,7 +130,7 @@ jobs:
cat cabal.project
nix-shell ghcjs.nix --run "cabal v2-update && cabal v2-freeze"
- uses: actions/cache@v2.1.3
- uses: actions/cache/save@v3
name: Cache ~/.cabal/store and dist-newstyle
with:
path: |
Expand Down
11 changes: 11 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ optimization: False
-- https://github.com/snoyberg/http-client/issues/508
constraints: crypton < 0, crypton-connection < 0, crypton-x509 < 0, crypton-x509-store < 0, crypton-x509-system < 0, crypton-x509-validation < 0
constraints: warp < 3.3.26

allow-newer: servant-js:base

-- Print ticks so that doctest type querying is consistent across GHC versions.
-- This block can be removed when we drop support for GHC 9.4 and below.
if(impl(ghc >= 9.6.1))
package servant
ghc-options: -fprint-redundant-promotion-ticks

package servant-server
ghc-options: -fprint-redundant-promotion-ticks
4 changes: 2 additions & 2 deletions servant-auth/servant-auth-client/servant-auth-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ library
default-extensions: ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators
ghc-options: -Wall
build-depends:
base >= 4.10 && < 4.18
base >= 4.10 && < 4.19
, bytestring >= 0.10.6.0 && < 0.12
, containers >= 0.5.6.2 && < 0.7
, servant-auth == 0.4.*
Expand Down Expand Up @@ -71,7 +71,7 @@ test-suite spec
, servant-auth-server >= 0.4.2.0 && < 0.5
, servant-server >= 0.13 && < 0.20
, time >= 1.5.0.1 && < 1.13
, transformers >= 0.4.2.0 && < 0.6
, transformers >= 0.4.2.0 && < 0.7
, wai >= 3.2.1.2 && < 3.3
, warp >= 3.2.25 && < 3.4
, jose >= 0.10 && < 0.11
Expand Down
4 changes: 2 additions & 2 deletions servant-auth/servant-auth-docs/servant-auth-docs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ library
default-extensions: ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators
ghc-options: -Wall
build-depends:
base >= 4.10 && < 4.18
base >= 4.10 && < 4.19
, servant-docs >= 0.11.2 && < 0.13
, servant >= 0.13 && < 0.20
, servant-auth == 0.4.*
Expand All @@ -50,7 +50,7 @@ test-suite doctests
build-depends:
base,
servant-auth-docs,
doctest >= 0.16 && < 0.21,
doctest >= 0.16 && < 0.22,
QuickCheck >= 2.11.3 && < 2.15,
template-haskell
ghc-options: -Wall -threaded
Expand Down
2 changes: 1 addition & 1 deletion servant-auth/servant-auth-server/servant-auth-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ library
default-extensions: ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators
ghc-options: -Wall
build-depends:
base >= 4.10 && < 4.18
base >= 4.10 && < 4.19
, aeson >= 1.0.0.1 && < 3
, base64-bytestring >= 1.0.0.1 && < 2
, blaze-builder >= 0.4.1.0 && < 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ library
default-extensions: ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators
ghc-options: -Wall
build-depends:
base >= 4.10 && < 4.18
base >= 4.10 && < 4.19
, text >= 1.2.3.0 && < 2.1
, servant-swagger >= 1.1.5 && < 2
, swagger2 >= 2.2.2 && < 3
Expand Down
2 changes: 1 addition & 1 deletion servant-auth/servant-auth/servant-auth.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ library
default-extensions: ConstraintKinds DataKinds DefaultSignatures DeriveFoldable DeriveFunctor DeriveGeneric DeriveTraversable FlexibleContexts FlexibleInstances FunctionalDependencies GADTs KindSignatures MultiParamTypeClasses OverloadedStrings RankNTypes ScopedTypeVariables TypeFamilies TypeOperators
ghc-options: -Wall
build-depends:
base >= 4.10 && < 4.18
base >= 4.10 && < 4.19
, containers >= 0.6 && < 0.7
, aeson >= 1.3.1.1 && < 3
, jose >= 0.10 && < 0.11
Expand Down
4 changes: 2 additions & 2 deletions servant-client-core/servant-client-core.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ library
--
-- note: mtl lower bound is so low because of GHC-7.8
build-depends:
base >= 4.9 && < 4.18
base >= 4.9 && < 4.19
, bytestring >= 0.10.8.1 && < 0.12
, constraints >= 0.2 && < 0.14
, containers >= 0.5.7.1 && < 0.7
, deepseq >= 1.4.2.0 && < 1.5
, text >= 1.2.3.0 && < 2.1
, transformers >= 0.5.2.0 && < 0.7
, template-haskell >= 2.11.1.0 && < 2.20
, template-haskell >= 2.11.1.0 && < 2.21

if !impl(ghc >= 8.2)
build-depends:
Expand Down
6 changes: 3 additions & 3 deletions servant-client-core/src/Servant/Client/Core/BaseUrl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ instance Eq BaseUrl where
where s ('/':x) = x
s x = x

-- | >>> traverse_ (LBS8.putStrLn . encode) $ parseBaseUrl "api.example.com"
-- | >>> traverse_ (LBS8.putStrLn . encode) (parseBaseUrl "api.example.com" :: [BaseUrl])
-- "http://api.example.com"
instance ToJSON BaseUrl where
toJSON = toJSON . showBaseUrl
Expand All @@ -72,8 +72,8 @@ instance FromJSON BaseUrl where

-- | >>> :{
-- traverse_ (LBS8.putStrLn . encode) $ do
-- u1 <- parseBaseUrl "api.example.com"
-- u2 <- parseBaseUrl "example.com"
-- u1 <- parseBaseUrl "api.example.com" :: [BaseUrl]
-- u2 <- parseBaseUrl "example.com" :: [BaseUrl]
-- return $ Map.fromList [(u1, 'x'), (u2, 'y')]
-- :}
-- {"http://api.example.com":"x","http://example.com":"y"}
Expand Down
2 changes: 1 addition & 1 deletion servant-client/servant-client.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ library
-- Bundled with GHC: Lower bound to not force re-installs
-- text and mtl are bundled starting with GHC-8.4
build-depends:
base >= 4.9 && < 4.18
base >= 4.9 && < 4.19
, bytestring >= 0.10.8.1 && < 0.12
, containers >= 0.5.7.1 && < 0.7
, deepseq >= 1.4.2.0 && < 1.5
Expand Down
4 changes: 2 additions & 2 deletions servant-docs/servant-docs.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ library
--
-- note: mtl lower bound is so low because of GHC-7.8
build-depends:
base >= 4.9 && < 4.18
base >= 4.9 && < 4.19
, bytestring >= 0.10.8.1 && < 0.12
, text >= 1.2.3.0 && < 2.1

Expand Down Expand Up @@ -105,4 +105,4 @@ test-suite spec
tasty >= 1.1.0.4 && < 1.5,
tasty-golden >= 2.3.2 && < 2.4,
tasty-hunit >= 0.10.0.1 && < 0.11,
transformers >= 0.5.2.0 && < 0.6
transformers >= 0.5.2.0 && < 0.7
2 changes: 1 addition & 1 deletion servant-foreign/servant-foreign.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ library
--
-- note: mtl lower bound is so low because of GHC-7.8
build-depends:
base >= 4.9 && < 4.18
base >= 4.9 && < 4.19
, text >= 1.2.3.0 && < 2.1

-- Servant dependencies
Expand Down
2 changes: 1 addition & 1 deletion servant-http-streams/servant-http-streams.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ library
-- Bundled with GHC: Lower bound to not force re-installs
-- text and mtl are bundled starting with GHC-8.4
build-depends:
base >= 4.9 && < 4.18
base >= 4.9 && < 4.19
, bytestring >= 0.10.8.1 && < 0.12
, containers >= 0.5.7.1 && < 0.7
, deepseq >= 1.4.2.0 && < 1.5
Expand Down
2 changes: 1 addition & 1 deletion servant-server/servant-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ library
-- Bundled with GHC: Lower bound to not force re-installs
-- text and mtl are bundled starting with GHC-8.4
build-depends:
base >= 4.9 && < 4.18
base >= 4.9 && < 4.19
, bytestring >= 0.10.8.1 && < 0.12
, constraints >= 0.2 && < 0.14
, containers >= 0.5.7.1 && < 0.7
Expand Down
2 changes: 1 addition & 1 deletion servant-server/src/Servant/Server/Internal/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ EmptyContext .++ a = a
--
-- >>> getContextEntry (True :. False :. EmptyContext) :: String
-- ...
-- ...No instance for (HasContextEntry '[] [Char])
-- ...No instance for ...HasContextEntry '[] [Char]...
-- ...
class HasContextEntry (context :: [*]) (val :: *) where
getContextEntry :: Context context -> val
Expand Down
2 changes: 1 addition & 1 deletion servant-swagger/servant-swagger.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ test-suite doctests
build-depends:
base,
directory >= 1.0,
doctest >= 0.17 && <0.21,
doctest >= 0.17 && <0.22,
servant,
QuickCheck,
filepath
Expand Down
2 changes: 1 addition & 1 deletion servant-swagger/src/Servant/Swagger/Internal/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import Servant.Swagger.Internal.TypeLevel
-- >>> type ContactAPI = Get '[JSON] Contact
-- >>> hspec $ validateEveryToJSON (Proxy :: Proxy ContactAPI)
-- ...
-- ...No instance for (Arbitrary Contact)
-- ...No instance for ...Arbitrary Contact...
-- ... arising from a use of ‘validateEveryToJSON’
-- ...
validateEveryToJSON
Expand Down
2 changes: 1 addition & 1 deletion servant/servant.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ library
--
-- note: mtl lower bound is so low because of GHC-7.8
build-depends:
base >= 4.9 && < 4.18
base >= 4.9 && < 4.19
, bytestring >= 0.10.8.1 && < 0.12
, constraints >= 0.2
, mtl ^>= 2.2.2 || ^>= 2.3.1
Expand Down
4 changes: 2 additions & 2 deletions servant/src/Servant/API/ResponseHeaders.hs
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ instance
--
-- 1. A simple value is wrapped in "Headers '[hdr]":
--
-- >>> let example1 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
-- >>> getHeaders example1
-- >>> let example0 = addHeader 5 "hi" :: Headers '[Header "someheader" Int] String;
-- >>> getHeaders example0
-- [("someheader","5")]
--
-- 2. A value that already has a header has its new header *prepended* to the
Expand Down
18 changes: 11 additions & 7 deletions servant/src/Servant/Types/SourceT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import System.IO
import qualified Test.QuickCheck as QC

-- $setup
-- >>> :set -XOverloadedStrings
-- >>> import Data.String (fromString)
-- >>> import Control.Monad.Except (runExcept)
-- >>> import Data.Foldable (toList)
-- >>> import qualified Data.Attoparsec.ByteString.Char8 as A8
Expand Down Expand Up @@ -67,7 +67,7 @@ fromStepT s = SourceT ($ s)
instance Functor m => Functor (SourceT m) where
fmap f = mapStepT (fmap f)

-- | >>> toList (source [1..10])
-- | >>> toList (source [1::Int .. 10])
-- [1,2,3,4,5,6,7,8,9,10]
--
instance Identity ~ m => Foldable (SourceT m) where
Expand Down Expand Up @@ -152,10 +152,14 @@ instance (Applicative m, Show1 m) => Show1 (StepT m) where
instance (Applicative m, Show1 m, Show a) => Show (StepT m a) where
showsPrec = showsPrec1

#if !MIN_VERSION_transformers(0,6,0)
-- Since transformers-0.6, MonadTrans only works on Monads.
-- StepT isn't necesssarily a monad. It doesn't have the Monad instance.
-- See https://gitlab.haskell.org/ghc/ghc/-/issues/19922

-- | >>> lift [1,2,3] :: StepT [] Int
-- Effect [Yield 1 Stop,Yield 2 Stop,Yield 3 Stop]
--
#if !MIN_VERSION_transformers(0,6,0)
instance MonadTrans StepT where
lift = Effect . fmap (`Yield` Stop)
#endif
Expand Down Expand Up @@ -345,16 +349,16 @@ readFile fp =
--
-- >>> let parser = A.skipWhile A8.isSpace_w8 >> A.takeWhile1 A8.isDigit_w8
--
-- >>> runExcept $ runSourceT $ transformWithAtto parser (source ["1 2 3"])
-- >>> runExcept $ runSourceT $ transformWithAtto parser (source $ [fromString "1 2 3"])
-- Right ["1","2","3"]
--
-- >>> runExcept $ runSourceT $ transformWithAtto parser (source ["1", "2", "3"])
-- >>> runExcept $ runSourceT $ transformWithAtto parser (source $ map fromString ["1", "2", "3"])
-- Right ["123"]
--
-- >>> runExcept $ runSourceT $ transformWithAtto parser (source ["1", "2 3", "4"])
-- >>> runExcept $ runSourceT $ transformWithAtto parser (source $ map fromString ["1", "2 3", "4"])
-- Right ["12","34"]
--
-- >>> runExcept $ runSourceT $ transformWithAtto parser (source ["foobar"])
-- >>> runExcept $ runSourceT $ transformWithAtto parser (source [fromString "foobar"])
-- Left "Failed reading: takeWhile1"
--
transformWithAtto :: Monad m => A.Parser a -> SourceT m BS.ByteString -> SourceT m a
Expand Down

0 comments on commit e9d283a

Please sign in to comment.