git.iko.soy/typeable/servant
on master help sign in
Rename EmptyAPIClient to EmptyClient
commit0bbc4f98a4f05f94309d4b7daddb38e735e2dac6 authorDavid Turner <dave.c.turner@gmail.com> dateTue 16 May 2017, 16:00 (9 years ago) parentf5d9983
3 files changed+8−10
doc/tutorial/Client.lhs+1−3 servant-client/src/Servant/Client.hs+6−6 servant-client/test/Servant/ClientSpec.hs+1−1
doc/tutorial/Client.lhs+1−3
@@ -77,8 +77,6 @@ hello :: Maybe String -- ^ an optional value for "name"
7777
7878marketing :: ClientInfo -- ^ value for the request body
7979 -> ClientM Email
80−
81−emptyClient :: EmptyAPIClient
8280```
8381
8482Each function makes available as an argument any value that the response may
@@ -91,7 +89,7 @@ the function `client`. It takes one argument:
9189api :: Proxy API
9290api = Proxy
9391
94−position :<|> hello :<|> marketing :<|> emptyClient = client api
92+position :<|> hello :<|> marketing :<|> EmptyClient = client api
9593```
9694
9795`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.
servant-client/src/Servant/Client.hs+6−6
@@ -24,7 +24,7 @@ module Servant.Client
2424 , ClientEnv (ClientEnv)
2525 , mkAuthenticateReq
2626 , ServantError(..)
27− , EmptyAPIClient(..)
27+ , EmptyClient(..)
2828 , module Servant.Common.BaseUrl
2929 ) where
3030
@@ -90,9 +90,9 @@ instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
9090 clientWithRoute (Proxy :: Proxy b) req
9191
9292-- | Singleton type representing a client for an empty API.
93−data EmptyAPIClient = EmptyAPIClient
93+data EmptyClient = EmptyClient deriving (Eq, Show, Bounded, Enum)
9494
95−-- | The client for 'EmptyAPI' is simply 'EmptyAPIClient'.
95+-- | The client for 'EmptyAPI' is simply 'EmptyClient'.
9696--
9797-- > type MyAPI = "books" :> Get '[JSON] [Book] -- GET /books
9898-- > :<|> "nothing" :> EmptyAPI
@@ -101,10 +101,10 @@ data EmptyAPIClient = EmptyAPIClient
101101-- > myApi = Proxy
102102-- >
103103-- > getAllBooks :: ClientM [Book]
104−-- > (getAllBooks :<|> EmptyAPIClient) = client myApi
104+-- > (getAllBooks :<|> EmptyClient) = client myApi
105105instance HasClient EmptyAPI where
106− type Client EmptyAPI = EmptyAPIClient
107− clientWithRoute Proxy _ = EmptyAPIClient
106+ type Client EmptyAPI = EmptyClient
107+ clientWithRoute Proxy _ = EmptyClient
108108
109109-- | If you use a 'Capture' in one of your endpoints in your API,
110110-- the corresponding querying function will automatically take
servant-client/test/Servant/ClientSpec.hs+1−1
@@ -146,7 +146,7 @@ getGet
146146 :<|> getMultiple
147147 :<|> getRespHeaders
148148 :<|> getDeleteContentType
149− :<|> EmptyAPIClient = client api
149+ :<|> EmptyClient = client api
150150
151151server :: Application
152152server = serve api (