Rename EmptyAPIClient to EmptyClient

This commit is contained in:
David Turner 2017-05-16 16:00:15 +00:00
parent f5d9983381
commit 0bbc4f98a4
3 changed files with 8 additions and 10 deletions

View File

@ -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.

View File

@ -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

View File

@ -146,7 +146,7 @@ getGet
:<|> getMultiple
:<|> getRespHeaders
:<|> getDeleteContentType
:<|> EmptyAPIClient = client api
:<|> EmptyClient = client api
server :: Application
server = serve api (