git.iko.soy/typeable/servant
on master help sign in
Updated documentation in Client.hs to reflect the changes to the client function
316737cmbg
servant-client/src/Servant/Client.hs+18−26
@@ -53,10 +53,9 @@ import Servant.Common.Req
53-- > myApi :: Proxy MyApi
53-- > myApi :: Proxy MyApi
54-- > myApi = Proxy
54-- > myApi = Proxy
55-- >
55-- >
56−-- > getAllBooks :: ExceptT String IO [Book]
56+-- > getAllBooks :: ClientM [Book]
57−-- > postNewBook :: Book -> ExceptT String IO Book
57+-- > postNewBook :: Book -> ClientM Book
58−-- > (getAllBooks :<|> postNewBook) = client myApi host manager
58+-- > (getAllBooks :<|> postNewBook) = client myApi
59−-- > where host = BaseUrl Http "localhost" 8080
60client :: HasClient layout => Proxy layout -> Client layout
59client :: HasClient layout => Proxy layout -> Client layout
61client p = clientWithRoute p defReq
60client p = clientWithRoute p defReq
62
61
@@ -78,10 +77,9 @@ class HasClient layout where
78-- > myApi :: Proxy MyApi
77-- > myApi :: Proxy MyApi
79-- > myApi = Proxy
78-- > myApi = Proxy
80-- >
79-- >
81−-- > getAllBooks :: ExceptT String IO [Book]
80+-- > getAllBooks :: ClientM [Book]
82−-- > postNewBook :: Book -> ExceptT String IO Book
81+-- > postNewBook :: Book -> ClientM Book
83−-- > (getAllBooks :<|> postNewBook) = client myApi host manager
82+-- > (getAllBooks :<|> postNewBook) = client myApi
84−-- > where host = BaseUrl Http "localhost" 8080
85instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
83instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
86 type Client (a :<|> b) = Client a :<|> Client b
84 type Client (a :<|> b) = Client a :<|> Client b
87 clientWithRoute Proxy req =
85 clientWithRoute Proxy req =
@@ -104,9 +102,8 @@ instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
104-- > myApi :: Proxy MyApi
102-- > myApi :: Proxy MyApi
105-- > myApi = Proxy
103-- > myApi = Proxy
106-- >
104-- >
107−-- > getBook :: Text -> ExceptT String IO Book
105+-- > getBook :: Text -> ClientM Book
108−-- > getBook = client myApi host manager
106+-- > getBook = client myApi
109−-- > where host = BaseUrl Http "localhost" 8080
110-- > -- then you can just use "getBook" to query that endpoint
107-- > -- then you can just use "getBook" to query that endpoint
111instance (KnownSymbol capture, ToHttpApiData a, HasClient sublayout)
108instance (KnownSymbol capture, ToHttpApiData a, HasClient sublayout)
112 => HasClient (Capture capture a :> sublayout) where
109 => HasClient (Capture capture a :> sublayout) where
@@ -182,9 +179,8 @@ instance OVERLAPPING_
182-- > myApi :: Proxy MyApi
179-- > myApi :: Proxy MyApi
183-- > myApi = Proxy
180-- > myApi = Proxy
184-- >
181-- >
185−-- > viewReferer :: Maybe Referer -> ExceptT String IO Book
182+-- > viewReferer :: Maybe Referer -> ClientM Book
186−-- > viewReferer = client myApi host
183+-- > viewReferer = client myApi
187−-- > where host = BaseUrl Http "localhost" 8080
188-- > -- then you can just use "viewRefer" to query that endpoint
184-- > -- then you can just use "viewRefer" to query that endpoint
189-- > -- specifying Nothing or e.g Just "http://haskell.org/" as arguments
185-- > -- specifying Nothing or e.g Just "http://haskell.org/" as arguments
190instance (KnownSymbol sym, ToHttpApiData a, HasClient sublayout)
186instance (KnownSymbol sym, ToHttpApiData a, HasClient sublayout)
@@ -233,9 +229,8 @@ instance HasClient sublayout
233-- > myApi :: Proxy MyApi
229-- > myApi :: Proxy MyApi
234-- > myApi = Proxy
230-- > myApi = Proxy
235-- >
231-- >
236−-- > getBooksBy :: Maybe Text -> ExceptT String IO [Book]
232+-- > getBooksBy :: Maybe Text -> ClientM [Book]
237−-- > getBooksBy = client myApi host
233+-- > getBooksBy = client myApi
238−-- > where host = BaseUrl Http "localhost" 8080
239-- > -- then you can just use "getBooksBy" to query that endpoint.
234-- > -- then you can just use "getBooksBy" to query that endpoint.
240-- > -- 'getBooksBy Nothing' for all books
235-- > -- 'getBooksBy Nothing' for all books
241-- > -- 'getBooksBy (Just "Isaac Asimov")' to get all books by Isaac Asimov
236-- > -- 'getBooksBy (Just "Isaac Asimov")' to get all books by Isaac Asimov
@@ -278,9 +273,8 @@ instance (KnownSymbol sym, ToHttpApiData a, HasClient sublayout)
278-- > myApi :: Proxy MyApi
273-- > myApi :: Proxy MyApi
279-- > myApi = Proxy
274-- > myApi = Proxy
280-- >
275-- >
281−-- > getBooksBy :: [Text] -> ExceptT String IO [Book]
276+-- > getBooksBy :: [Text] -> ClientM [Book]
282−-- > getBooksBy = client myApi host
277+-- > getBooksBy = client myApi
283−-- > where host = BaseUrl Http "localhost" 8080
284-- > -- then you can just use "getBooksBy" to query that endpoint.
278-- > -- then you can just use "getBooksBy" to query that endpoint.
285-- > -- 'getBooksBy []' for all books
279-- > -- 'getBooksBy []' for all books
286-- > -- 'getBooksBy ["Isaac Asimov", "Robert A. Heinlein"]'
280-- > -- 'getBooksBy ["Isaac Asimov", "Robert A. Heinlein"]'
@@ -318,9 +312,8 @@ instance (KnownSymbol sym, ToHttpApiData a, HasClient sublayout)
318-- > myApi :: Proxy MyApi
312-- > myApi :: Proxy MyApi
319-- > myApi = Proxy
313-- > myApi = Proxy
320-- >
314-- >
321−-- > getBooks :: Bool -> ExceptT String IO [Book]
315+-- > getBooks :: Bool -> ClientM [Book]
322−-- > getBooks = client myApi host
316+-- > getBooks = client myApi
323−-- > where host = BaseUrl Http "localhost" 8080
324-- > -- then you can just use "getBooks" to query that endpoint.
317-- > -- then you can just use "getBooks" to query that endpoint.
325-- > -- 'getBooksBy False' for all books
318-- > -- 'getBooksBy False' for all books
326-- > -- 'getBooksBy True' to only get _already published_ books
319-- > -- 'getBooksBy True' to only get _already published_ books
@@ -365,9 +358,8 @@ instance HasClient Raw where
365-- > myApi :: Proxy MyApi
358-- > myApi :: Proxy MyApi
366-- > myApi = Proxy
359-- > myApi = Proxy
367-- >
360-- >
368−-- > addBook :: Book -> ExceptT String IO Book
361+-- > addBook :: Book -> ClientM Book
369−-- > addBook = client myApi host manager
362+-- > addBook = client myApi
370−-- > where host = BaseUrl Http "localhost" 8080
371-- > -- then you can just use "addBook" to query that endpoint
363-- > -- then you can just use "addBook" to query that endpoint
372instance (MimeRender ct a, HasClient sublayout)
364instance (MimeRender ct a, HasClient sublayout)
373 => HasClient (ReqBody (ct ': cts) a :> sublayout) where
365 => HasClient (ReqBody (ct ': cts) a :> sublayout) where