servant 0.19 → 0.19.1
raw patch · 7 files changed
+49/−18 lines, 7 filesdep ~basedep ~base-compatdep ~http-api-data
Dependency ranges changed: base, base-compat, http-api-data
Files
- CHANGELOG.md +8/−3
- servant.cabal +8/−8
- src/Servant/API.hs +4/−0
- src/Servant/API/ContentTypes.hs +1/−1
- src/Servant/API/TypeLevel.hs +3/−3
- src/Servant/Links.hs +14/−3
- test/Servant/API/ContentTypesSpec.hs +11/−0
CHANGELOG.md view
@@ -2,6 +2,11 @@ Package versions follow the [Package Versioning Policy](https://pvp.haskell.org/): in A.B.C, bumps to either A or B represent major versions. +0.19.1+------++Compatibility with GHC 9.4, see [PR #1592](https://github.com/haskell-servant/servant/pull/1592).+ 0.19 ---- @@ -48,11 +53,11 @@ rootClient :: RootApi (AsClientT ClientM) rootClient = client (Proxy @API) - hello :: String -> ClientM String- hello name = rootClient // hello /: name+ helloClient :: String -> ClientM String+ helloClient name = rootClient // hello /: name endpointClient :: ClientM Person- endpointClient = client // subApi /: "foobar123" // endpoint+ endpointClient = rootClient // subApi /: "foobar123" // endpoint type Api = NamedRoutes RootApi
servant.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: servant-version: 0.19+version: 0.19.1 synopsis: A family of combinators for defining webservices APIs category: Servant, Web@@ -80,25 +80,25 @@ -- -- note: mtl lower bound is so low because of GHC-7.8 build-depends:- base >= 4.9 && < 4.16+ base >= 4.9 && < 4.18 , bytestring >= 0.10.8.1 && < 0.12 , constraints >= 0.2 , mtl >= 2.2.2 && < 2.3 , sop-core >= 0.4.0.0 && < 0.6 , transformers >= 0.5.2.0 && < 0.6- , text >= 1.2.3.0 && < 1.3+ , text >= 1.2.3.0 && < 2.1 -- We depend (heavily) on the API of these packages: -- i.e. re-export, or allow using without direct dependency build-depends:- http-api-data >= 0.4.1 && < 0.4.4+ http-api-data >= 0.4.1 && < 0.5.1 , singleton-bool >= 0.1.4 && < 0.1.7 -- 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.10.5 && < 0.13 , aeson >= 1.4.1.0 && < 3 , attoparsec >= 0.13.2.2 && < 0.15 , bifunctors >= 5.5.3 && < 5.6@@ -106,7 +106,7 @@ , deepseq >= 1.4.2.0 && < 1.5 , http-media >= 0.7.1.3 && < 0.9 , http-types >= 0.12.2 && < 0.13- , mmorph >= 1.1.2 && < 1.2+ , mmorph >= 1.1.2 && < 1.3 , network-uri >= 2.6.1.0 && < 2.7 , QuickCheck >= 2.12.6.1 && < 2.15 , string-conversions >= 0.4.0.1 && < 0.5@@ -166,9 +166,9 @@ -- Additional dependencies build-depends:- hspec >= 2.6.0 && < 2.9+ hspec >= 2.6.0 && < 2.10 , QuickCheck >= 2.12.6.1 && < 2.15 , quickcheck-instances >= 0.3.19 && < 0.4 build-tool-depends:- hspec-discover:hspec-discover >= 2.6.0 && < 2.9+ hspec-discover:hspec-discover >= 2.6.0 && < 2.10
src/Servant/API.hs view
@@ -38,6 +38,7 @@ -- * Sub-APIs defined as records of routes module Servant.API.NamedRoutes,+ module Servant.API.Generic, -- * Streaming endpoints, distinguished by HTTP method module Servant.API.Stream,@@ -102,6 +103,9 @@ (Fragment) import Servant.API.Header (Header, Header')+import Servant.API.Generic+ (GenericMode ((:-)), AsApi, ToServant, ToServantApi, GServantProduct,+ GenericServant, fromServant, toServant, genericApi) import Servant.API.HttpVersion (HttpVersion (..)) import Servant.API.IsSecure
src/Servant/API/ContentTypes.hs view
@@ -295,7 +295,7 @@ -- then this would be taken care of. However there is no more specific instance -- between that and 'MimeRender JSON a', so we do this instead instance {-# OVERLAPPING #-} ( Accept ctyp ) => AllMimeRender '[ctyp] NoContent where- allMimeRender _ _ = map (, "") $ NE.toList $ contentTypes pctyp+ allMimeRender _ NoContent = map (, "") $ NE.toList $ contentTypes pctyp where pctyp = Proxy :: Proxy ctyp
src/Servant/API/TypeLevel.hs view
@@ -110,7 +110,7 @@ -- -- >>> ok (Proxy :: Proxy (IsElem ("bye" :> Get '[JSON] Int) SampleAPI)) -- ...--- ... Could not deduce...+-- ... Could not ... -- ... -- -- An endpoint is considered within an api even if it is missing combinators@@ -151,7 +151,7 @@ -- -- >>> ok (Proxy :: Proxy (IsSubAPI (SampleAPI :<|> Get '[JSON] Int) SampleAPI)) -- ...--- ... Could not deduce...+-- ... Could not ... -- ... -- -- This uses @IsElem@ for checking; thus the note there applies here.@@ -174,7 +174,7 @@ -- -- >>> ok (Proxy :: Proxy (IsIn (Get '[JSON] Int) (Header "h" Bool :> Get '[JSON] Int))) -- ...--- ... Could not deduce...+-- ... Could not ... -- ... type family IsIn (endpoint :: *) (api :: *) :: Constraint where IsIn e (sa :<|> sb) = Or (IsIn e sa) (IsIn e sb)
src/Servant/Links.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE AllowAmbiguousTypes #-} {-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-}@@ -91,7 +92,7 @@ -- >>> let bad_link = Proxy :: Proxy ("hello" :> Delete '[JSON] NoContent) -- >>> safeLink api bad_link -- ...--- ...Could not deduce...+-- ...Could not ... -- ... -- -- This error is essentially saying that the type family couldn't find@@ -193,6 +194,8 @@ import Servant.API.WithNamedContext (WithNamedContext) import Web.HttpApiData+import Data.Kind+ (Type) -- | A safe link datatype. -- The only way of constructing a 'Link' is using 'safeLink', which means any@@ -647,12 +650,20 @@ -- >>> import Data.Text (Text) -- Erroring instance for 'HasLink' when a combinator is not fully applied-instance TypeError (PartialApplication HasLink arr) => HasLink ((arr :: a -> b) :> sub)+instance TypeError (PartialApplication +#if __GLASGOW_HASKELL__ >= 904+ @(Type -> Constraint) +#endif+ HasLink arr) => HasLink ((arr :: a -> b) :> sub) where type MkLink (arr :> sub) _ = TypeError (PartialApplication (HasLink :: * -> Constraint) arr) toLink = error "unreachable" -- Erroring instances for 'HasLink' for unknown API combinators-instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub HasLink ty) => HasLink (ty :> sub)+instance {-# OVERLAPPABLE #-} TypeError (NoInstanceForSub +#if __GLASGOW_HASKELL__ >= 904+ @(Type -> Constraint) +#endif+ HasLink ty) => HasLink (ty :> sub) instance {-# OVERLAPPABLE #-} TypeError (NoInstanceFor (HasLink api)) => HasLink api
test/Servant/API/ContentTypesSpec.hs view
@@ -33,6 +33,8 @@ import qualified Data.Text as TextS import qualified Data.Text.Encoding as TextSE import qualified Data.Text.Lazy as TextL+import Control.Exception+ (evaluate) import GHC.Generics import Test.Hspec import Test.QuickCheck@@ -77,6 +79,15 @@ it "has mimeUnrender reverse mimeRender for valid top-level json " $ do property $ \x -> mimeUnrender p (mimeRender p x) == Right (x::SomeData)++ describe "The NoContent Content-Type type" $ do+ let p = Proxy :: Proxy '[JSON]++ it "does not render any content" $+ allMimeRender p NoContent `shouldSatisfy` (all (BSL8.null . snd))++ it "evaluates the NoContent value" $+ evaluate (allMimeRender p (undefined :: NoContent)) `shouldThrow` anyErrorCall describe "The PlainText Content-Type type" $ do let p = Proxy :: Proxy PlainText