Skip to content

Commit d33f626

Browse files
authored
Remove extraneous dependencies (part 2) (#1745)
* Remove extraneous dependencies
1 parent 584dd02 commit d33f626

File tree

19 files changed

+233
-358
lines changed

19 files changed

+233
-358
lines changed

servant-client-core/servant-client-core.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ library
5555
, containers >= 0.5.7.1 && < 0.7
5656
, deepseq >= 1.4.2.0 && < 1.6
5757
, text >= 1.2.3.0 && < 2.2
58-
, transformers >= 0.5.2.0 && < 0.7
5958
, template-haskell >= 2.11.1.0 && < 2.22
6059

6160
if !impl(ghc >= 8.2)

servant-client/test/Servant/StreamSpec.hs

-20
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE ConstraintKinds #-}
33
{-# LANGUAGE DataKinds #-}
4-
{-# LANGUAGE DeriveGeneric #-}
54
{-# LANGUAGE FlexibleContexts #-}
65
{-# LANGUAGE FlexibleInstances #-}
7-
{-# LANGUAGE FunctionalDependencies #-}
86
{-# LANGUAGE GADTs #-}
97
{-# LANGUAGE MultiParamTypeClasses #-}
108
{-# LANGUAGE OverloadedStrings #-}
119
{-# LANGUAGE PolyKinds #-}
12-
{-# LANGUAGE RecordWildCards #-}
1310
{-# LANGUAGE ScopedTypeVariables #-}
14-
{-# LANGUAGE StandaloneDeriving #-}
1511
{-# LANGUAGE TypeFamilies #-}
1612
{-# LANGUAGE TypeOperators #-}
1713
{-# LANGUAGE UndecidableInstances #-}
@@ -21,12 +17,6 @@
2117

2218
module Servant.StreamSpec (spec) where
2319

24-
import Control.Monad
25-
(when)
26-
import Control.Monad.Codensity
27-
(Codensity (..))
28-
import Control.Monad.IO.Class
29-
(MonadIO (..))
3020
import Control.Monad.Trans.Except
3121
import qualified Data.ByteString as BS
3222
import Data.Proxy
@@ -45,20 +35,10 @@ import System.Entropy
4535
(getEntropy, getHardwareEntropy)
4636
import System.IO.Unsafe
4737
(unsafePerformIO)
48-
import System.Mem
49-
(performGC)
5038
import Test.Hspec
5139
import Servant.ClientTestUtils (Person(..))
5240
import qualified Servant.ClientTestUtils as CT
5341

54-
#if MIN_VERSION_base(4,10,0)
55-
import GHC.Stats
56-
(gc, gcdetails_live_bytes, getRTSStats)
57-
#else
58-
import GHC.Stats
59-
(currentBytesUsed, getGCStats)
60-
#endif
61-
6242
-- This declaration simply checks that all instances are in place.
6343
-- Note: this is streaming client
6444
_ = client comprehensiveAPI

servant-client/test/Servant/SuccessSpec.hs

+19-33
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
{-# LANGUAGE ScopedTypeVariables #-}
1111
{-# LANGUAGE TypeApplications #-}
1212
{-# LANGUAGE TypeFamilies #-}
13-
{-# LANGUAGE TypeOperators #-}
1413
{-# LANGUAGE UndecidableInstances #-}
1514
{-# OPTIONS_GHC -freduction-depth=100 #-}
1615
{-# OPTIONS_GHC -fno-warn-orphans #-}
@@ -22,13 +21,11 @@ import Prelude ()
2221
import Prelude.Compat
2322

2423
import Control.Arrow
25-
((+++), left)
24+
(left)
2625
import Control.Concurrent.STM
2726
(atomically)
2827
import Control.Concurrent.STM.TVar
2928
(newTVar, readTVar)
30-
import qualified Data.ByteString as BS
31-
import qualified Data.ByteString.Lazy as BL
3229
import Data.Foldable
3330
(forM_, toList)
3431
import Data.Maybe
@@ -56,30 +53,23 @@ import Servant.Test.ComprehensiveAPI
5653
_ = client comprehensiveAPIWithoutStreaming
5754

5855
spec :: Spec
59-
spec = describe "Servant.SuccessSpec" $ do
60-
successSpec
56+
spec = describe "Servant.SuccessSpec" $ successSpec
6157

6258
successSpec :: Spec
6359
successSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
6460
describe "Servant.API.Get" $ do
65-
it "get root endpoint" $ \(_, baseUrl) -> do
66-
left show <$> runClient getRoot baseUrl `shouldReturn` Right carol
61+
it "get root endpoint" $ \(_, baseUrl) -> left show <$> runClient getRoot baseUrl `shouldReturn` Right carol
6762

68-
it "get simple endpoint" $ \(_, baseUrl) -> do
69-
left show <$> runClient getGet baseUrl `shouldReturn` Right alice
63+
it "get simple endpoint" $ \(_, baseUrl) -> left show <$> runClient getGet baseUrl `shouldReturn` Right alice
7064

71-
it "get redirection endpoint" $ \(_, baseUrl) -> do
72-
left show <$> runClient getGet307 baseUrl `shouldReturn` Right "redirecting"
65+
it "get redirection endpoint" $ \(_, baseUrl) -> left show <$> runClient getGet307 baseUrl `shouldReturn` Right "redirecting"
7366

7467
describe "Servant.API.Delete" $ do
75-
it "allows empty content type" $ \(_, baseUrl) -> do
76-
left show <$> runClient getDeleteEmpty baseUrl `shouldReturn` Right NoContent
68+
it "allows empty content type" $ \(_, baseUrl) -> left show <$> runClient getDeleteEmpty baseUrl `shouldReturn` Right NoContent
7769

78-
it "allows content type" $ \(_, baseUrl) -> do
79-
left show <$> runClient getDeleteContentType baseUrl `shouldReturn` Right NoContent
70+
it "allows content type" $ \(_, baseUrl) -> left show <$> runClient getDeleteContentType baseUrl `shouldReturn` Right NoContent
8071

81-
it "Servant.API.Capture" $ \(_, baseUrl) -> do
82-
left show <$> runClient (getCapture "Paula") baseUrl `shouldReturn` Right (Person "Paula" 0)
72+
it "Servant.API.Capture" $ \(_, baseUrl) -> left show <$> runClient (getCapture "Paula") baseUrl `shouldReturn` Right (Person "Paula" 0)
8373

8474
it "Servant.API.CaptureAll" $ \(_, baseUrl) -> do
8575
let expected = [Person "Paula" 0, Person "Peta" 1]
@@ -107,18 +97,15 @@ successSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
10797
`shouldReturn` Right [Person "alice" 0, Person "bob" 1]
10898

10999
context "Servant.API.QueryParam.QueryFlag" $
110-
forM_ [False, True] $ \ flag -> it (show flag) $ \(_, baseUrl) -> do
111-
left show <$> runClient (getQueryFlag flag) baseUrl `shouldReturn` Right flag
100+
forM_ [False, True] $ \ flag -> it (show flag) $ \(_, baseUrl) -> left show <$> runClient (getQueryFlag flag) baseUrl `shouldReturn` Right flag
112101

113102
it "Servant.API.QueryParam.QueryString" $ \(_, baseUrl) -> do
114103
let qs = [("name", Just "bob"), ("age", Just "1")]
115-
left show <$> runClient (getQueryString qs) baseUrl `shouldReturn` (Right (Person "bob" 1))
104+
left show <$> runClient (getQueryString qs) baseUrl `shouldReturn` Right (Person "bob" 1)
116105

117-
it "Servant.API.QueryParam.DeepQuery" $ \(_, baseUrl) -> do
118-
left show <$> runClient (getDeepQuery $ Filter 1 "bob") baseUrl `shouldReturn` (Right (Person "bob" 1))
106+
it "Servant.API.QueryParam.DeepQuery" $ \(_, baseUrl) -> left show <$> runClient (getDeepQuery $ Filter 1 "bob") baseUrl `shouldReturn` (Right (Person "bob" 1))
119107

120-
it "Servant.API.Fragment" $ \(_, baseUrl) -> do
121-
left id <$> runClient getFragment baseUrl `shouldReturn` Right alice
108+
it "Servant.API.Fragment" $ \(_, baseUrl) -> left id <$> runClient getFragment baseUrl `shouldReturn` Right alice
122109

123110
it "Servant.API.Raw on success" $ \(_, baseUrl) -> do
124111
res <- runClient (getRawSuccess HTTP.methodGet) baseUrl
@@ -180,13 +167,12 @@ successSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
180167
Right r ->
181168
("X-Added-Header", "XXX") `elem` toList (responseHeaders r) `shouldBe` True
182169

183-
modifyMaxSuccess (const 20) $ do
184-
it "works for a combination of Capture, QueryParam, QueryFlag and ReqBody" $ \(_, baseUrl) ->
185-
property $ forAllShrink pathGen shrink $ \(NonEmpty cap) num flag body ->
186-
ioProperty $ do
187-
result <- left show <$> runClient (getMultiple cap num flag body) baseUrl
188-
return $
189-
result === Right (cap, num, flag, body)
170+
modifyMaxSuccess (const 20) $ it "works for a combination of Capture, QueryParam, QueryFlag and ReqBody" $ \(_, baseUrl) ->
171+
property $ forAllShrink pathGen shrink $ \(NonEmpty cap) num flag body ->
172+
ioProperty $ do
173+
result <- left show <$> runClient (getMultiple cap num flag body) baseUrl
174+
return $
175+
result === Right (cap, num, flag, body)
190176

191177
context "With a route that can either return success or redirect" $ do
192178
it "Redirects when appropriate" $ \(_, baseUrl) -> do
@@ -203,7 +189,7 @@ successSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
203189

204190
context "with a route that uses uverb but only has a single response" $
205191
it "returns the expected response" $ \(_, baseUrl) -> do
206-
eitherResponse <- runClient (uverbGetCreated) baseUrl
192+
eitherResponse <- runClient uverbGetCreated baseUrl
207193
case eitherResponse of
208194
Left clientError -> fail $ show clientError
209195
Right response -> matchUnion response `shouldBe` Just (WithStatus @201 carol)

servant-docs/golden/comprehensive.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@
544544

545545
- Example (`application/json;charset=utf-8`, `application/json`):
546546

547-
```javascript
547+
```json
548548

549549
```
550550

@@ -607,3 +607,4 @@
607607
```json
608608

609609
```
610+

servant-quickcheck/servant-quickcheck.cabal

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ library
5454
, servant-client >=0.17 && <0.21
5555
, servant-server >=0.17 && <0.21
5656
, split >=0.2 && <0.3
57-
, string-conversions >=0.3 && <0.5
5857
, temporary >=1.2 && <1.4
5958
, text >=1 && <2.2
6059
, time >=1.5 && <1.13

servant-quickcheck/src/Servant/QuickCheck/Internal/ErrorTypes.hs

+14-16
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Servant.QuickCheck.Internal.ErrorTypes where
33

44
import Control.Exception (Exception (..))
55
import qualified Data.ByteString.Lazy as LBS
6-
import Data.String.Conversions (cs)
6+
import qualified Data.ByteString.Char8 as BS8
77
import qualified Data.Text as T
88
import Data.Typeable (Typeable)
99
import GHC.Generics (Generic)
@@ -12,6 +12,7 @@ import Network.HTTP.Types (Header, statusCode)
1212
import Text.PrettyPrint
1313

1414
import Prelude.Compat hiding ((<>))
15+
import qualified Data.ByteString.Lazy.Char8 as BSL8
1516

1617
data PredicateFailure
1718
= PredicateFailure T.Text (Maybe C.Request) (C.Response LBS.ByteString)
@@ -42,37 +43,34 @@ prettyHeaders hdrs = vcat $ prettyHdr <$> hdrs
4243

4344
prettyReq :: C.Request -> Doc
4445
prettyReq r =
45-
text "Request:" $$ (nest 5 $
46-
text "Method:" <+> (nest 5 $ text . show $ C.method r)
47-
$$ text "Path:" <+> (nest 5 $ text . cs $ C.path r)
48-
$$ text "Headers:" <+> (nest 5 $ prettyHeaders $ C.requestHeaders r)
49-
$$ text "Body:" <+> (nest 5 $ text . getReqBody $ C.requestBody r))
46+
text "Request:" $$ nest 5 (text "Method:" <+> nest 5 (text . show $ C.method r)
47+
$$ text "Path:" <+> nest 5 (text . BS8.unpack $ C.path r)
48+
$$ text "Headers:" <+> nest 5 (prettyHeaders $ C.requestHeaders r)
49+
$$ text "Body:" <+> nest 5 (text . getReqBody $ C.requestBody r))
5050
where
51-
getReqBody (C.RequestBodyLBS lbs ) = cs lbs
52-
getReqBody (C.RequestBodyBS bs ) = cs bs
51+
getReqBody :: C.RequestBody -> String
52+
getReqBody (C.RequestBodyLBS lbs ) = BSL8.unpack lbs
53+
getReqBody (C.RequestBodyBS bs ) = BS8.unpack bs
5354
getReqBody _ = error "expected bytestring body"
5455

5556
prettyResp :: C.Response LBS.ByteString -> Doc
5657
prettyResp r =
57-
text "Response:" $$ (nest 5 $
58-
text "Status code:" <+> (nest 5 $ text . show . statusCode $ C.responseStatus r)
59-
$$ text "Headers:" $$ (nest 10 $ prettyHeaders $ C.responseHeaders r)
60-
$$ text "Body:" <+> (nest 5 $ text . cs $ C.responseBody r))
58+
text "Response:" $$ nest 5 (text "Status code:" <+> nest 5 (text . show . statusCode $ C.responseStatus r)
59+
$$ text "Headers:" $$ nest 10 (prettyHeaders $ C.responseHeaders r)
60+
$$ text "Body:" <+> nest 5 (text . BSL8.unpack $ C.responseBody r))
6161

6262

6363

6464
prettyServerEqualityFailure :: ServerEqualityFailure -> Doc
6565
prettyServerEqualityFailure (ServerEqualityFailure req resp1 resp2) =
66-
text "Server equality failed" $$ (nest 5 $
67-
prettyReq req
66+
text "Server equality failed" $$ nest 5 (prettyReq req
6867
$$ prettyResp resp1
6968
$$ prettyResp resp2)
7069

7170

7271
prettyPredicateFailure :: PredicateFailure -> Doc
7372
prettyPredicateFailure (PredicateFailure predicate req resp) =
74-
text "Predicate failed" $$ (nest 5 $
75-
text "Predicate:" <+> (text $ T.unpack predicate)
73+
text "Predicate failed" $$ nest 5 (text "Predicate:" <+> text (T.unpack predicate)
7674
$$ r
7775
$$ prettyResp resp)
7876
where

servant-quickcheck/src/Servant/QuickCheck/Internal/HasGenRequest.hs

+13-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module Servant.QuickCheck.Internal.HasGenRequest where
55

66
import Data.Kind (Type)
77
import Data.String (fromString)
8-
import Data.String.Conversions (cs)
8+
import qualified Data.Text.Encoding as Text
9+
import qualified Data.ByteString.Char8 as BS8
910
import GHC.TypeLits (KnownSymbol, Nat, symbolVal)
1011
import Network.HTTP.Client (Request, RequestBody (..),
1112
defaultRequest, host, method, path,
@@ -65,7 +66,7 @@ instance (KnownSymbol path, HasGenRequest b) => HasGenRequest (path :> b) where
6566
in r { path = "/" <> BS.intercalate "/" paths })
6667
where
6768
(oldf, old) = genRequest (Proxy :: Proxy b)
68-
new = cs $ symbolVal (Proxy :: Proxy path)
69+
new = BS8.pack $ symbolVal (Proxy :: Proxy path)
6970

7071
instance HasGenRequest EmptyAPI where
7172
genRequest _ = (0, error "EmptyAPIs cannot be queried.")
@@ -80,7 +81,7 @@ instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
8081
genRequest _ = (oldf, do
8182
old' <- old
8283
new' <- toUrlPiece <$> new
83-
return $ \burl -> let r = old' burl in r { path = cs new' <> path r })
84+
return $ \burl -> let r = old' burl in r { path = Text.encodeUtf8 new' <> path r })
8485
where
8586
(oldf, old) = genRequest (Proxy :: Proxy b)
8687
new = arbitrary :: Gen c
@@ -89,7 +90,7 @@ instance (Arbitrary c, HasGenRequest b, ToHttpApiData c )
8990
=> HasGenRequest (CaptureAll x c :> b) where
9091
genRequest _ = (oldf, do
9192
old' <- old
92-
new' <- fmap (cs . toUrlPiece) <$> new
93+
new' <- fmap (Text.encodeUtf8 . toUrlPiece) <$> new
9394
let new'' = BS.intercalate "/" new'
9495
return $ \burl -> let r = old' burl in r { path = new'' <> path r })
9596
where
@@ -102,7 +103,7 @@ instance (Arbitrary c, KnownSymbol h, HasGenRequest b, ToHttpApiData c)
102103
old' <- old
103104
new' <- toUrlPiece <$> new -- TODO: generate lenient or/and optional
104105
return $ \burl -> let r = old' burl in r {
105-
requestHeaders = (hdr, cs new') : requestHeaders r })
106+
requestHeaders = (hdr, Text.encodeUtf8 new') : requestHeaders r })
106107
where
107108
(oldf, old) = genRequest (Proxy :: Proxy b)
108109
hdr = fromString $ symbolVal (Proxy :: Proxy h)
@@ -128,12 +129,12 @@ instance (KnownSymbol x, Arbitrary c, ToHttpApiData c, HasGenRequest b)
128129
new' <- new -- TODO: generate lenient or/and optional
129130
old' <- old
130131
return $ \burl -> let r = old' burl
131-
newExpr = param <> "=" <> cs (toQueryParam new')
132+
newExpr = param <> "=" <> Text.encodeUtf8 (toQueryParam new')
132133
qs = queryString r in r {
133134
queryString = if BS.null qs then newExpr else newExpr <> "&" <> qs })
134135
where
135136
(oldf, old) = genRequest (Proxy :: Proxy b)
136-
param = cs $ symbolVal (Proxy :: Proxy x)
137+
param = BS8.pack $ symbolVal (Proxy :: Proxy x)
137138
new = arbitrary :: Gen c
138139

139140
instance (KnownSymbol x, Arbitrary c, ToHttpApiData c, HasGenRequest b)
@@ -146,9 +147,9 @@ instance (KnownSymbol x, Arbitrary c, ToHttpApiData c, HasGenRequest b)
146147
<> if not (null new') then fold (toParam <$> new') else ""})
147148
where
148149
(oldf, old) = genRequest (Proxy :: Proxy b)
149-
param = cs $ symbolVal (Proxy :: Proxy x)
150+
param = BS8.pack $ symbolVal (Proxy :: Proxy x)
150151
new = arbitrary :: Gen [c]
151-
toParam c = param <> "[]=" <> cs (toQueryParam c)
152+
toParam c = param <> "[]=" <> Text.encodeUtf8 (toQueryParam c)
152153
fold = foldr1 (\a b -> a <> "&" <> b)
153154

154155
instance (KnownSymbol x, HasGenRequest b)
@@ -160,12 +161,12 @@ instance (KnownSymbol x, HasGenRequest b)
160161
queryString = if BS.null qs then param else param <> "&" <> qs })
161162
where
162163
(oldf, old) = genRequest (Proxy :: Proxy b)
163-
param = cs $ symbolVal (Proxy :: Proxy x)
164+
param = BS8.pack $ symbolVal (Proxy :: Proxy x)
164165

165166
instance (ReflectMethod method)
166167
=> HasGenRequest (Verb (method :: k) (status :: Nat) (cts :: [Type]) a) where
167168
genRequest _ = (1, return $ \burl -> defaultRequest
168-
{ host = cs $ baseUrlHost burl
169+
{ host = BS8.pack $ baseUrlHost burl
169170
, port = baseUrlPort burl
170171
, secure = baseUrlScheme burl == Https
171172
, method = reflectMethod (Proxy :: Proxy method)
@@ -174,7 +175,7 @@ instance (ReflectMethod method)
174175
instance (ReflectMethod method)
175176
=> HasGenRequest (NoContentVerb (method :: k)) where
176177
genRequest _ = (1, return $ \burl -> defaultRequest
177-
{ host = cs $ baseUrlHost burl
178+
{ host = BS8.pack $ baseUrlHost burl
178179
, port = baseUrlPort burl
179180
, secure = baseUrlScheme burl == Https
180181
, method = reflectMethod (Proxy :: Proxy method)

servant-server/servant-server.cabal

-8
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,13 @@ library
7878
-- Other dependencies: Lower bound around what is in the latest Stackage LTS.
7979
-- Here can be exceptions if we really need features from the newer versions.
8080
build-depends:
81-
base-compat >= 0.10.5 && < 0.14
8281
, base64-bytestring >= 1.0.0.1 && < 1.3
8382
, exceptions >= 0.10.0 && < 0.11
8483
, http-media >= 0.7.1.3 && < 0.9
8584
, http-types >= 0.12.2 && < 0.13
86-
, network-uri >= 2.6.1.0 && < 2.8
8785
, monad-control >= 1.0.2.3 && < 1.1
8886
, network >= 2.8 && < 3.3
8987
, sop-core >= 0.4.0.0 && < 0.6
90-
, string-conversions >= 0.4.0.1 && < 0.5
9188
, resourcet >= 1.2.2 && < 1.4
9289
, tagged >= 0.8.6 && < 0.9
9390
, transformers-base >= 0.4.5.2 && < 0.5
@@ -148,11 +145,7 @@ test-suite spec
148145
, safe
149146
, servant
150147
, servant-server
151-
, sop-core
152-
, string-conversions
153148
, text
154-
, transformers
155-
, transformers-compat
156149
, wai
157150

158151
-- Additional dependencies
@@ -161,7 +154,6 @@ test-suite spec
161154
, directory >= 1.3.0.0 && < 1.4
162155
, hspec >= 2.6.0 && < 2.12
163156
, hspec-wai >= 0.10.1 && < 0.12
164-
, QuickCheck >= 2.12.6.1 && < 2.15
165157
, should-not-typecheck >= 2.1.0 && < 2.2
166158
, temporary >= 1.3 && < 1.4
167159
, wai-extra >= 3.0.24.3 && < 3.2

0 commit comments

Comments
 (0)