From e6daf03c165871cc0cc4f346e15cadb049078117 Mon Sep 17 00:00:00 2001 From: Maxim Koltsov Date: Thu, 30 Jul 2020 19:22:14 +0300 Subject: [PATCH] Support servant-server-0.18 --- cabal.project | 2 ++ servant-quickcheck.cabal | 6 +++--- src/Servant/QuickCheck/Internal/QuickCheck.hs | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cabal.project b/cabal.project index b0a523c..7713844 100644 --- a/cabal.project +++ b/cabal.project @@ -1,2 +1,4 @@ packages: . tests: true + +allow-newer: servant-blaze:servant diff --git a/servant-quickcheck.cabal b/servant-quickcheck.cabal index d5ea6e3..51d522f 100644 --- a/servant-quickcheck.cabal +++ b/servant-quickcheck.cabal @@ -49,9 +49,9 @@ library , pretty >=1.1 && <1.2 , process >=1.2 && <1.7 , QuickCheck >=2.7 && <2.15 - , servant >=0.17 && <0.18 - , servant-client >=0.17 && <0.18 - , servant-server >=0.17 && <0.18 + , servant >=0.17 && <0.19 + , servant-client >=0.17 && <0.19 + , servant-server >=0.17 && <0.19 , split >=0.2 && <0.3 , string-conversions >=0.3 && <0.5 , temporary >=1.2 && <1.4 diff --git a/src/Servant/QuickCheck/Internal/QuickCheck.hs b/src/Servant/QuickCheck/Internal/QuickCheck.hs index 2a1b678..6b2a952 100644 --- a/src/Servant/QuickCheck/Internal/QuickCheck.hs +++ b/src/Servant/QuickCheck/Internal/QuickCheck.hs @@ -11,6 +11,9 @@ import Network.Wai.Handler.Warp (withApplication) import Prelude.Compat import Servant (Context (EmptyContext), HasServer, Server, serveWithContext) +#if MIN_VERSION_servant_server(0,18,0) +import Servant (DefaultErrorFormatters, ErrorFormatters, HasContextEntry, type (.++)) +#endif import Servant.Client (BaseUrl (..), Scheme (..)) import System.IO.Unsafe (unsafePerformIO) import Test.Hspec (Expectation, expectationFailure) @@ -37,8 +40,13 @@ withServantServer api = withServantServerAndContext api EmptyContext -- application. -- -- /Since 0.0.0.0/ +#if MIN_VERSION_servant_server(0,18,0) +withServantServerAndContext :: (HasServer a ctx, HasContextEntry (ctx .++ DefaultErrorFormatters) ErrorFormatters) + => Proxy a -> Context ctx -> IO (Server a) -> (BaseUrl -> IO r) -> IO r +#else withServantServerAndContext :: HasServer a ctx => Proxy a -> Context ctx -> IO (Server a) -> (BaseUrl -> IO r) -> IO r +#endif withServantServerAndContext api ctx server t = withApplication (return . serveWithContext api ctx =<< server) $ \port -> t (BaseUrl Http "localhost" port "")