diff --git a/servant-client-core/src/Servant/Client/Core/HasClient.hs b/servant-client-core/src/Servant/Client/Core/HasClient.hs index fe2a15f8..80f85802 100644 --- a/servant-client-core/src/Servant/Client/Core/HasClient.hs +++ b/servant-client-core/src/Servant/Client/Core/HasClient.hs @@ -32,7 +32,6 @@ import Control.Arrow (left, (+++)) import Control.Monad (unless) -import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy as BL import Data.Either (partitionEithers) @@ -78,7 +77,7 @@ import Servant.API ReflectMethod (..), RemoteHost, ReqBody', SBoolI, Stream, StreamBody', Summary, ToHttpApiData, ToSourceIO (..), Vault, Verb, WithNamedContext, WithStatus (..), contentType, getHeadersHList, - getResponse, toEncodedUrlPiece, toUrlPiece, NamedRoutes) + getResponse, toEncodedUrlPiece, NamedRoutes) import Servant.API.Generic (GenericMode(..), ToServant, ToServantApi , GenericServant, toServant, fromServant) diff --git a/servant-client/src/Servant/Client/Internal/HttpClient.hs b/servant-client/src/Servant/Client/Internal/HttpClient.hs index 8db0c9f2..999805dc 100644 --- a/servant-client/src/Servant/Client/Internal/HttpClient.hs +++ b/servant-client/src/Servant/Client/Internal/HttpClient.hs @@ -43,14 +43,12 @@ import qualified Data.ByteString as BS import Data.ByteString.Builder (toLazyByteString) import qualified Data.ByteString.Lazy as BSL -import Data.Either - (either) import Data.Foldable (foldl',toList) import Data.Functor.Alt (Alt (..)) import Data.Maybe - (maybe, maybeToList) + (maybeToList) import Data.Proxy (Proxy (..)) import Data.Sequence @@ -63,7 +61,7 @@ import GHC.Generics import Network.HTTP.Media (renderHeader) import Network.HTTP.Types - (hContentType, renderQuery, statusIsSuccessful, urlEncode, Status) + (hContentType, statusIsSuccessful, urlEncode, Status) import Servant.Client.Core import qualified Network.HTTP.Client as Client diff --git a/servant-client/src/Servant/Client/Internal/HttpClient/Streaming.hs b/servant-client/src/Servant/Client/Internal/HttpClient/Streaming.hs index 41a06572..0b5a79de 100644 --- a/servant-client/src/Servant/Client/Internal/HttpClient/Streaming.hs +++ b/servant-client/src/Servant/Client/Internal/HttpClient/Streaming.hs @@ -24,8 +24,6 @@ import Control.DeepSeq (NFData, force) import Control.Exception (evaluate, throwIO) -import Control.Monad - (unless) import Control.Monad.Base (MonadBase (..)) import Control.Monad.Codensity diff --git a/servant-client/test/Servant/StreamSpec.hs b/servant-client/test/Servant/StreamSpec.hs index 85018576..0afa53dd 100644 --- a/servant-client/test/Servant/StreamSpec.hs +++ b/servant-client/test/Servant/StreamSpec.hs @@ -21,16 +21,9 @@ module Servant.StreamSpec (spec) where -import Control.Monad - (when) -import Control.Monad.Codensity - (Codensity (..)) -import Control.Monad.IO.Class - (MonadIO (..)) import Control.Monad.Trans.Except import qualified Data.ByteString as BS import Data.Proxy -import qualified Data.TDigest as TD import qualified Network.HTTP.Client as C import Prelude () import Prelude.Compat @@ -46,20 +39,10 @@ import System.Entropy (getEntropy, getHardwareEntropy) import System.IO.Unsafe (unsafePerformIO) -import System.Mem - (performGC) import Test.Hspec import Servant.ClientTestUtils (Person(..)) import qualified Servant.ClientTestUtils as CT -#if MIN_VERSION_base(4,10,0) -import GHC.Stats - (gc, gcdetails_live_bytes, getRTSStats) -#else -import GHC.Stats - (currentBytesUsed, getGCStats) -#endif - -- This declaration simply checks that all instances are in place. -- Note: this is streaming client _ = client comprehensiveAPI @@ -78,9 +61,9 @@ api :: Proxy StreamApi api = Proxy getGetNL, getGetNS :: ClientM (SourceIO Person) -getGetALot :: ClientM (SourceIO BS.ByteString) +_getGetALot :: ClientM (SourceIO BS.ByteString) getStreamBody :: SourceT IO BS.ByteString -> ClientM (SourceIO BS.ByteString) -getGetNL :<|> getGetNS :<|> getGetALot :<|> getStreamBody = client api +getGetNL :<|> getGetNS :<|> _getGetALot :<|> getStreamBody = client api alice :: Person alice = Person "Alice" 42 @@ -134,50 +117,3 @@ streamSpec = beforeAll (CT.startWaiApp server) $ afterAll CT.endWaiApp $ do where input = ["foo", "", "bar"] output = ["foo", "bar"] - -{- - it "streams in constant memory" $ \(_, baseUrl) -> do - Right rs <- runClient getGetALot baseUrl - performGC - -- usage0 <- getUsage - -- putStrLn $ "Start: " ++ show usage0 - tdigest <- memoryUsage $ joinCodensitySourceT rs - - -- putStrLn $ "Median: " ++ show (TD.median tdigest) - -- putStrLn $ "Mean: " ++ show (TD.mean tdigest) - -- putStrLn $ "Stddev: " ++ show (TD.stddev tdigest) - - -- forM_ [0.01, 0.1, 0.2, 0.5, 0.8, 0.9, 0.99] $ \q -> - -- putStrLn $ "q" ++ show q ++ ": " ++ show (TD.quantile q tdigest) - - let Just stddev = TD.stddev tdigest - - -- standard deviation of 100k is ok, we generate 256M of data after all. - -- On my machine deviation is 40k-50k - stddev `shouldSatisfy` (< 100000) - -memoryUsage :: SourceT IO BS.ByteString -> IO (TD.TDigest 25) -memoryUsage src = unSourceT src $ loop mempty (0 :: Int) - where - loop !acc !_ Stop = return acc - loop !_ !_ (Error err) = fail err -- ! - loop !acc !n (Skip s) = loop acc n s - loop !acc !n (Effect ms) = ms >>= loop acc n - loop !acc !n (Yield _bs s) = do - usage <- liftIO getUsage - -- We perform GC in between as we generate garbage. - when (n `mod` 1024 == 0) $ liftIO performGC - loop (TD.insert usage acc) (n + 1) s - -getUsage :: IO Double -getUsage = fromIntegral . -#if MIN_VERSION_base(4,10,0) - gcdetails_live_bytes . gc <$> getRTSStats -#else - currentBytesUsed <$> getGCStats -#endif - memUsed `shouldSatisfy` (< megabytes 22) - -megabytes :: Num a => a -> a -megabytes n = n * (1000 ^ (2 :: Int)) --} diff --git a/servant-conduit/example/Main.hs b/servant-conduit/example/Main.hs index 85ababe0..a50bb707 100644 --- a/servant-conduit/example/Main.hs +++ b/servant-conduit/example/Main.hs @@ -17,8 +17,6 @@ import Data.Maybe (fromMaybe) import Network.HTTP.Client (defaultManagerSettings, newManager) -import Network.Wai - (Application) import System.Environment (getArgs, lookupEnv) import Text.Read diff --git a/servant-docs/src/Servant/Docs/Internal.hs b/servant-docs/src/Servant/Docs/Internal.hs index b5c4bf1f..e545a035 100644 --- a/servant-docs/src/Servant/Docs/Internal.hs +++ b/servant-docs/src/Servant/Docs/Internal.hs @@ -55,7 +55,7 @@ import Data.String.Conversions import Data.Text (Text, unpack) import GHC.Generics - (Generic, Rep, K1(K1), M1(M1), U1(U1), V1, + (K1(K1), M1(M1), U1(U1), V1, (:*:)((:*:)), (:+:)(L1, R1)) import qualified GHC.Generics as G import GHC.TypeLits @@ -964,7 +964,7 @@ instance {-# OVERLAPPABLE #-} instance (ReflectMethod method) => HasDocs (NoContentVerb method) where - docsFor Proxy (endpoint, action) DocOptions{..} = + docsFor Proxy (endpoint, action) _ = single endpoint' action' where endpoint' = endpoint & method .~ method' @@ -982,7 +982,7 @@ instance (ReflectMethod method) => instance {-# OVERLAPPABLE #-} (Accept ct, KnownNat status, ReflectMethod method) => HasDocs (Stream method status framing ct a) where - docsFor Proxy (endpoint, action) DocOptions{..} = + docsFor Proxy (endpoint, action) _ = single endpoint' action' where endpoint' = endpoint & method .~ method' diff --git a/servant-machines/example/Main.hs b/servant-machines/example/Main.hs index 3f1a0bd6..0ea35cf7 100644 --- a/servant-machines/example/Main.hs +++ b/servant-machines/example/Main.hs @@ -17,8 +17,6 @@ import Data.Void (Void) import Network.HTTP.Client (defaultManagerSettings, newManager) -import Network.Wai - (Application) import System.Environment (getArgs, lookupEnv) import Text.Read diff --git a/servant-pipes/example/Main.hs b/servant-pipes/example/Main.hs index 8683f651..6d0f1f38 100644 --- a/servant-pipes/example/Main.hs +++ b/servant-pipes/example/Main.hs @@ -15,8 +15,6 @@ import Data.Maybe (fromMaybe) import Network.HTTP.Client (defaultManagerSettings, newManager) -import Network.Wai - (Application) import System.Environment (getArgs, lookupEnv) import System.IO diff --git a/servant-server/src/Servant/Server/Internal.hs b/servant-server/src/Servant/Server/Internal.hs index a4d74564..7702ac0b 100644 --- a/servant-server/src/Servant/Server/Internal.hs +++ b/servant-server/src/Servant/Server/Internal.hs @@ -95,8 +95,6 @@ import Servant.API.TypeErrors import Web.HttpApiData (FromHttpApiData, parseHeader, parseQueryParam, parseUrlPiece, parseUrlPieces) -import Data.Kind - (Type) import Servant.Server.Internal.BasicAuth import Servant.Server.Internal.Context @@ -110,7 +108,7 @@ import Servant.Server.Internal.RoutingApplication import Servant.Server.Internal.ServerError import GHC.TypeLits - (ErrorMessage (..), TypeError) + (ErrorMessage (..)) import Servant.API.TypeLevel (AtLeastOneFragment, FragmentUnique) diff --git a/servant-swagger/src/Servant/Swagger/Internal.hs b/servant-swagger/src/Servant/Swagger/Internal.hs index 66cb0595..82dde9ee 100644 --- a/servant-swagger/src/Servant/Swagger/Internal.hs +++ b/servant-swagger/src/Servant/Swagger/Internal.hs @@ -38,7 +38,6 @@ import Network.HTTP.Media (MediaType) import Servant.API import Servant.API.Description (FoldDescription, reflectDescription) -import Servant.API.Generic (ToServantApi, AsApi) import Servant.API.Modifiers (FoldRequired) import Servant.Swagger.Internal.TypeLevel.API diff --git a/servant/src/Servant/API/TypeErrors.hs b/servant/src/Servant/API/TypeErrors.hs index e0c7080d..0cb2cda8 100644 --- a/servant/src/Servant/API/TypeErrors.hs +++ b/servant/src/Servant/API/TypeErrors.hs @@ -16,7 +16,6 @@ module Servant.API.TypeErrors ( NoInstanceForSub, ) where -import Data.Kind import GHC.TypeLits -- | No instance exists for @tycls (expr :> ...)@ because