@@ -25,7 +25,7 @@ module Servant.Client
2525import Control.Applicative ((<$>))
2626#endif
2727import Control.Monad
28−import Control.Monad.Trans.Either
28+import Control.Monad.Trans.Except
2929import Data.ByteString.Lazy (ByteString)
3030import Data.List
3131import Data.Proxy
@@ -50,8 +50,8 @@ import Servant.Common.Req
5050-- > myApi :: Proxy MyApi
5151-- > myApi = Proxy
5252-- >
53−-- > getAllBooks :: EitherT String IO [Book]
54−-- > postNewBook :: Book -> EitherT String IO Book
53+-- > getAllBooks :: ExceptT String IO [Book]
54+-- > postNewBook :: Book -> ExceptT String IO Book
5555-- > (getAllBooks :<|> postNewBook) = client myApi host
5656-- > where host = BaseUrl Http "localhost" 8080
5757client :: HasClient layout => Proxy layout -> BaseUrl -> Client layout
@@ -76,8 +76,8 @@ class HasClient layout where
7676-- > myApi :: Proxy MyApi
7777-- > myApi = Proxy
7878-- >
79−-- > getAllBooks :: EitherT String IO [Book]
80−-- > postNewBook :: Book -> EitherT String IO Book
79+-- > getAllBooks :: ExceptT String IO [Book]
80+-- > postNewBook :: Book -> ExceptT String IO Book
8181-- > (getAllBooks :<|> postNewBook) = client myApi host
8282-- > where host = BaseUrl Http "localhost" 8080
8383instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
@@ -102,7 +102,7 @@ instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
102102-- > myApi :: Proxy MyApi
103103-- > myApi = Proxy
104104-- >
105−-- > getBook :: Text -> EitherT String IO Book
105+-- > getBook :: Text -> ExceptT String IO Book
106106-- > getBook = client myApi host
107107-- > where host = BaseUrl Http "localhost" 8080
108108-- > -- then you can just use "getBook" to query that endpoint
@@ -129,7 +129,7 @@ instance
129129#endif
130130 -- See https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_guide/type-class-extensions.html#undecidable-instances
131131 (MimeUnrender ct a, cts' ~ (ct ': cts)) => HasClient (Delete cts' a) where
132− type Client (Delete cts' a) = EitherT ServantError IO a
132+ type Client (Delete cts' a) = ExceptT ServantError IO a
133133 clientWithRoute Proxy req baseurl =
134134 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] baseurl
135135
@@ -140,7 +140,7 @@ instance
140140 {-# OVERLAPPING #-}
141141#endif
142142 HasClient (Delete cts ()) where
143− type Client (Delete cts ()) = EitherT ServantError IO ()
143+ type Client (Delete cts ()) = ExceptT ServantError IO ()
144144 clientWithRoute Proxy req baseurl =
145145 void $ performRequestNoBody H.methodDelete req [204] baseurl
146146
@@ -153,7 +153,7 @@ instance
153153 -- See https://downloads.haskell.org/~ghc/7.8.2/docs/html/users_guide/type-class-extensions.html#undecidable-instances
154154 ( MimeUnrender ct a, BuildHeadersTo ls, cts' ~ (ct ': cts)
155155 ) => HasClient (Delete cts' (Headers ls a)) where
156− type Client (Delete cts' (Headers ls a)) = EitherT ServantError IO (Headers ls a)
156+ type Client (Delete cts' (Headers ls a)) = ExceptT ServantError IO (Headers ls a)
157157 clientWithRoute Proxy req baseurl = do
158158 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] baseurl
159159 return $ Headers { getResponse = resp
@@ -169,7 +169,7 @@ instance
169169 {-# OVERLAPPABLE #-}
170170#endif
171171 (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
172− type Client (Get (ct ': cts) result) = EitherT ServantError IO result
172+ type Client (Get (ct ': cts) result) = ExceptT ServantError IO result
173173 clientWithRoute Proxy req baseurl =
174174 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] baseurl
175175
@@ -180,7 +180,7 @@ instance
180180 {-# OVERLAPPING #-}
181181#endif
182182 HasClient (Get (ct ': cts) ()) where
183− type Client (Get (ct ': cts) ()) = EitherT ServantError IO ()
183+ type Client (Get (ct ': cts) ()) = ExceptT ServantError IO ()
184184 clientWithRoute Proxy req baseurl =
185185 performRequestNoBody H.methodGet req [204] baseurl
186186
@@ -192,7 +192,7 @@ instance
192192#endif
193193 ( MimeUnrender ct a, BuildHeadersTo ls
194194 ) => HasClient (Get (ct ': cts) (Headers ls a)) where
195− type Client (Get (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
195+ type Client (Get (ct ': cts) (Headers ls a)) = ExceptT ServantError IO (Headers ls a)
196196 clientWithRoute Proxy req baseurl = do
197197 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203, 204] baseurl
198198 return $ Headers { getResponse = resp
@@ -220,7 +220,7 @@ instance
220220-- > myApi :: Proxy MyApi
221221-- > myApi = Proxy
222222-- >
223−-- > viewReferer :: Maybe Referer -> EitherT String IO Book
223+-- > viewReferer :: Maybe Referer -> ExceptT String IO Book
224224-- > viewReferer = client myApi host
225225-- > where host = BaseUrl Http "localhost" 8080
226226-- > -- then you can just use "viewRefer" to query that endpoint
@@ -250,7 +250,7 @@ instance
250250 {-# OVERLAPPABLE #-}
251251#endif
252252 (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
253− type Client (Post (ct ': cts) a) = EitherT ServantError IO a
253+ type Client (Post (ct ': cts) a) = ExceptT ServantError IO a
254254 clientWithRoute Proxy req baseurl =
255255 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPost req [200,201] baseurl
256256
@@ -261,7 +261,7 @@ instance
261261 {-# OVERLAPPING #-}
262262#endif
263263 HasClient (Post (ct ': cts) ()) where
264− type Client (Post (ct ': cts) ()) = EitherT ServantError IO ()
264+ type Client (Post (ct ': cts) ()) = ExceptT ServantError IO ()
265265 clientWithRoute Proxy req baseurl =
266266 void $ performRequestNoBody H.methodPost req [204] baseurl
267267
@@ -273,7 +273,7 @@ instance
273273#endif
274274 ( MimeUnrender ct a, BuildHeadersTo ls
275275 ) => HasClient (Post (ct ': cts) (Headers ls a)) where
276− type Client (Post (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
276+ type Client (Post (ct ': cts) (Headers ls a)) = ExceptT ServantError IO (Headers ls a)
277277 clientWithRoute Proxy req baseurl = do
278278 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPost req [200, 201] baseurl
279279 return $ Headers { getResponse = resp
@@ -289,7 +289,7 @@ instance
289289 {-# OVERLAPPABLE #-}
290290#endif
291291 (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
292− type Client (Put (ct ': cts) a) = EitherT ServantError IO a
292+ type Client (Put (ct ': cts) a) = ExceptT ServantError IO a
293293 clientWithRoute Proxy req baseurl =
294294 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPut req [200,201] baseurl
295295
@@ -300,7 +300,7 @@ instance
300300 {-# OVERLAPPING #-}
301301#endif
302302 HasClient (Put (ct ': cts) ()) where
303− type Client (Put (ct ': cts) ()) = EitherT ServantError IO ()
303+ type Client (Put (ct ': cts) ()) = ExceptT ServantError IO ()
304304 clientWithRoute Proxy req baseurl =
305305 void $ performRequestNoBody H.methodPut req [204] baseurl
306306
@@ -312,7 +312,7 @@ instance
312312#endif
313313 ( MimeUnrender ct a, BuildHeadersTo ls
314314 ) => HasClient (Put (ct ': cts) (Headers ls a)) where
315− type Client (Put (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
315+ type Client (Put (ct ': cts) (Headers ls a)) = ExceptT ServantError IO (Headers ls a)
316316 clientWithRoute Proxy req baseurl = do
317317 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPut req [200, 201] baseurl
318318 return $ Headers { getResponse = resp
@@ -328,7 +328,7 @@ instance
328328 {-# OVERLAPPABLE #-}
329329#endif
330330 (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
331− type Client (Patch (ct ': cts) a) = EitherT ServantError IO a
331+ type Client (Patch (ct ': cts) a) = ExceptT ServantError IO a
332332 clientWithRoute Proxy req baseurl =
333333 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200,201] baseurl
334334
@@ -339,7 +339,7 @@ instance
339339 {-# OVERLAPPING #-}
340340#endif
341341 HasClient (Patch (ct ': cts) ()) where
342− type Client (Patch (ct ': cts) ()) = EitherT ServantError IO ()
342+ type Client (Patch (ct ': cts) ()) = ExceptT ServantError IO ()
343343 clientWithRoute Proxy req baseurl =
344344 void $ performRequestNoBody H.methodPatch req [204] baseurl
345345
@@ -351,7 +351,7 @@ instance
351351#endif
352352 ( MimeUnrender ct a, BuildHeadersTo ls
353353 ) => HasClient (Patch (ct ': cts) (Headers ls a)) where
354− type Client (Patch (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
354+ type Client (Patch (ct ': cts) (Headers ls a)) = ExceptT ServantError IO (Headers ls a)
355355 clientWithRoute Proxy req baseurl = do
356356 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200, 201, 204] baseurl
357357 return $ Headers { getResponse = resp
@@ -378,7 +378,7 @@ instance
378378-- > myApi :: Proxy MyApi
379379-- > myApi = Proxy
380380-- >
381−-- > getBooksBy :: Maybe Text -> EitherT String IO [Book]
381+-- > getBooksBy :: Maybe Text -> ExceptT String IO [Book]
382382-- > getBooksBy = client myApi host
383383-- > where host = BaseUrl Http "localhost" 8080
384384-- > -- then you can just use "getBooksBy" to query that endpoint.
@@ -424,7 +424,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
424424-- > myApi :: Proxy MyApi
425425-- > myApi = Proxy
426426-- >
427−-- > getBooksBy :: [Text] -> EitherT String IO [Book]
427+-- > getBooksBy :: [Text] -> ExceptT String IO [Book]
428428-- > getBooksBy = client myApi host
429429-- > where host = BaseUrl Http "localhost" 8080
430430-- > -- then you can just use "getBooksBy" to query that endpoint.
@@ -465,7 +465,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
465465-- > myApi :: Proxy MyApi
466466-- > myApi = Proxy
467467-- >
468−-- > getBooks :: Bool -> EitherT String IO [Book]
468+-- > getBooks :: Bool -> ExceptT String IO [Book]
469469-- > getBooks = client myApi host
470470-- > where host = BaseUrl Http "localhost" 8080
471471-- > -- then you can just use "getBooks" to query that endpoint.
@@ -507,7 +507,7 @@ instance (KnownSymbol sym, HasClient sublayout)
507507-- > myApi :: Proxy MyApi
508508-- > myApi = Proxy
509509-- >
510−-- > getBooksBy :: Maybe Text -> EitherT String IO [Book]
510+-- > getBooksBy :: Maybe Text -> ExceptT String IO [Book]
511511-- > getBooksBy = client myApi host
512512-- > where host = BaseUrl Http "localhost" 8080
513513-- > -- then you can just use "getBooksBy" to query that endpoint.
@@ -552,7 +552,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
552552-- > myApi :: Proxy MyApi
553553-- > myApi = Proxy
554554-- >
555−-- > getBooksBy :: [Text] -> EitherT String IO [Book]
555+-- > getBooksBy :: [Text] -> ExceptT String IO [Book]
556556-- > getBooksBy = client myApi host
557557-- > where host = BaseUrl Http "localhost" 8080
558558-- > -- then you can just use "getBooksBy" to query that endpoint.
@@ -593,7 +593,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
593593-- > myApi :: Proxy MyApi
594594-- > myApi = Proxy
595595-- >
596−-- > getBooks :: Bool -> EitherT String IO [Book]
596+-- > getBooks :: Bool -> ExceptT String IO [Book]
597597-- > getBooks = client myApi host
598598-- > where host = BaseUrl Http "localhost" 8080
599599-- > -- then you can just use "getBooks" to query that endpoint.
@@ -618,7 +618,7 @@ instance (KnownSymbol sym, HasClient sublayout)
618618-- | Pick a 'Method' and specify where the server you want to query is. You get
619619-- back the full `Response`.
620620instance HasClient Raw where
621− type Client Raw = H.Method -> EitherT ServantError IO (Int, ByteString, MediaType, [HTTP.Header], Response ByteString)
621+ type Client Raw = H.Method -> ExceptT ServantError IO (Int, ByteString, MediaType, [HTTP.Header], Response ByteString)
622622
623623 clientWithRoute :: Proxy Raw -> Req -> BaseUrl -> Client Raw
624624 clientWithRoute Proxy req baseurl httpMethod = do
@@ -639,7 +639,7 @@ instance HasClient Raw where
639639-- > myApi :: Proxy MyApi
640640-- > myApi = Proxy
641641-- >
642−-- > addBook :: Book -> EitherT String IO Book
642+-- > addBook :: Book -> ExceptT String IO Book
643643-- > addBook = client myApi host
644644-- > where host = BaseUrl Http "localhost" 8080
645645-- > -- then you can just use "addBook" to query that endpoint