From 0bbc4f98a4f05f94309d4b7daddb38e735e2dac6 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 16 May 2017 16:00:15 +0000 Subject: [PATCH] Rename EmptyAPIClient to EmptyClient --- doc/tutorial/Client.lhs | 4 +--- servant-client/src/Servant/Client.hs | 12 ++++++------ servant-client/test/Servant/ClientSpec.hs | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/tutorial/Client.lhs b/doc/tutorial/Client.lhs index d409a437..cb8a24b7 100644 --- a/doc/tutorial/Client.lhs +++ b/doc/tutorial/Client.lhs @@ -77,8 +77,6 @@ hello :: Maybe String -- ^ an optional value for "name" marketing :: ClientInfo -- ^ value for the request body -> ClientM Email - -emptyClient :: EmptyAPIClient ``` Each function makes available as an argument any value that the response may @@ -91,7 +89,7 @@ the function `client`. It takes one argument: api :: Proxy API api = Proxy -position :<|> hello :<|> marketing :<|> emptyClient = client api +position :<|> hello :<|> marketing :<|> EmptyClient = client api ``` `client api` returns client functions for our _entire_ API, combined with `:<|>`, which we can pattern match on as above. You could say `client` "calculates" the correct type and number of client functions for the API type it is given (via a `Proxy`), as well as their implementations. diff --git a/servant-client/src/Servant/Client.hs b/servant-client/src/Servant/Client.hs index cf1ce9e7..dfe2721c 100644 --- a/servant-client/src/Servant/Client.hs +++ b/servant-client/src/Servant/Client.hs @@ -24,7 +24,7 @@ module Servant.Client , ClientEnv (ClientEnv) , mkAuthenticateReq , ServantError(..) - , EmptyAPIClient(..) + , EmptyClient(..) , module Servant.Common.BaseUrl ) where @@ -90,9 +90,9 @@ instance (HasClient a, HasClient b) => HasClient (a :<|> b) where clientWithRoute (Proxy :: Proxy b) req -- | Singleton type representing a client for an empty API. -data EmptyAPIClient = EmptyAPIClient +data EmptyClient = EmptyClient deriving (Eq, Show, Bounded, Enum) --- | The client for 'EmptyAPI' is simply 'EmptyAPIClient'. +-- | The client for 'EmptyAPI' is simply 'EmptyClient'. -- -- > type MyAPI = "books" :> Get '[JSON] [Book] -- GET /books -- > :<|> "nothing" :> EmptyAPI @@ -101,10 +101,10 @@ data EmptyAPIClient = EmptyAPIClient -- > myApi = Proxy -- > -- > getAllBooks :: ClientM [Book] --- > (getAllBooks :<|> EmptyAPIClient) = client myApi +-- > (getAllBooks :<|> EmptyClient) = client myApi instance HasClient EmptyAPI where - type Client EmptyAPI = EmptyAPIClient - clientWithRoute Proxy _ = EmptyAPIClient + type Client EmptyAPI = EmptyClient + clientWithRoute Proxy _ = EmptyClient -- | If you use a 'Capture' in one of your endpoints in your API, -- the corresponding querying function will automatically take diff --git a/servant-client/test/Servant/ClientSpec.hs b/servant-client/test/Servant/ClientSpec.hs index 3a4a2481..14e9f917 100644 --- a/servant-client/test/Servant/ClientSpec.hs +++ b/servant-client/test/Servant/ClientSpec.hs @@ -146,7 +146,7 @@ getGet :<|> getMultiple :<|> getRespHeaders :<|> getDeleteContentType - :<|> EmptyAPIClient = client api + :<|> EmptyClient = client api server :: Application server = serve api (