on master help sign in
clean up Client and remove Setup binary
bc8efb2Brandon Martin
servant-client/servant-client.cabal−1
@@ -85,4 +85,3 @@ test-suite spec
85 , text
85 , text
86 , wai
86 , wai
87 , warp
87 , warp
88− , transformers
servant-client/src/Servant/Client.hs+31−31
@@ -59,10 +59,10 @@ client p baseurl = clientWithRoute p defReq baseurl
59-- influences the creation of an HTTP request. It's mostly
59-- influences the creation of an HTTP request. It's mostly
60-- an internal class, you can just use 'client'.
60-- an internal class, you can just use 'client'.
61class HasClient layout where
61class HasClient layout where
62− type Client' layout :: *
62+ type Client layout :: *
63− clientWithRoute :: Proxy layout -> Req -> BaseUrl -> Client' layout
63+ clientWithRoute :: Proxy layout -> Req -> BaseUrl -> Client layout
64
64
65−type Client layout = Client' layout
65+{-type Client layout = Client layout-}
66
66
67-- | A client querying function for @a ':<|>' b@ will actually hand you
67-- | A client querying function for @a ':<|>' b@ will actually hand you
68-- one function for querying @a@ and another one for querying @b@,
68-- one function for querying @a@ and another one for querying @b@,
@@ -78,7 +78,7 @@ type Client layout = Client' layout
78-- > postNewBook :: Book -> BaseUrl -> EitherT String IO Book
78-- > postNewBook :: Book -> BaseUrl -> EitherT String IO Book
79-- > (getAllBooks :<|> postNewBook) = client myApi
79-- > (getAllBooks :<|> postNewBook) = client myApi
80instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
80instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
81− type Client' (a :<|> b) = Client' a :<|> Client' b
81+ type Client (a :<|> b) = Client a :<|> Client b
82 clientWithRoute Proxy req baseurl =
82 clientWithRoute Proxy req baseurl =
83 clientWithRoute (Proxy :: Proxy a) req baseurl :<|>
83 clientWithRoute (Proxy :: Proxy a) req baseurl :<|>
84 clientWithRoute (Proxy :: Proxy b) req baseurl
84 clientWithRoute (Proxy :: Proxy b) req baseurl
@@ -105,7 +105,7 @@ instance (HasClient a, HasClient b) => HasClient (a :<|> b) where
105instance (KnownSymbol capture, ToText a, HasClient sublayout)
105instance (KnownSymbol capture, ToText a, HasClient sublayout)
106 => HasClient (Capture capture a :> sublayout) where
106 => HasClient (Capture capture a :> sublayout) where
107
107
108− type Client' (Capture capture a :> sublayout) =
108+ type Client (Capture capture a :> sublayout) =
109 a -> Client sublayout
109 a -> Client sublayout
110
110
111 clientWithRoute Proxy req baseurl val =
111 clientWithRoute Proxy req baseurl val =
@@ -124,7 +124,7 @@ instance
124 {-# OVERLAPPABLE #-}
124 {-# OVERLAPPABLE #-}
125#endif
125#endif
126 (MimeUnrender ct a) => HasClient (Delete (ct ': cts) a) where
126 (MimeUnrender ct a) => HasClient (Delete (ct ': cts) a) where
127− type Client' (Delete (ct ': cts) a) = EitherT ServantError IO a
127+ type Client (Delete (ct ': cts) a) = EitherT ServantError IO a
128 clientWithRoute Proxy req baseurl =
128 clientWithRoute Proxy req baseurl =
129 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] baseurl
129 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] baseurl
130
130
@@ -135,7 +135,7 @@ instance
135 {-# OVERLAPPING #-}
135 {-# OVERLAPPING #-}
136#endif
136#endif
137 HasClient (Delete (ct ': cts) ()) where
137 HasClient (Delete (ct ': cts) ()) where
138− type Client' (Delete (ct ': cts) ()) = EitherT ServantError IO ()
138+ type Client (Delete (ct ': cts) ()) = EitherT ServantError IO ()
139 clientWithRoute Proxy req baseurl =
139 clientWithRoute Proxy req baseurl =
140 void $ performRequestNoBody H.methodDelete req [204] baseurl
140 void $ performRequestNoBody H.methodDelete req [204] baseurl
141
141
@@ -147,7 +147,7 @@ instance
147#endif
147#endif
148 ( MimeUnrender ct a, BuildHeadersTo ls
148 ( MimeUnrender ct a, BuildHeadersTo ls
149 ) => HasClient (Delete (ct ': cts) (Headers ls a)) where
149 ) => HasClient (Delete (ct ': cts) (Headers ls a)) where
150− type Client' (Delete (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
150+ type Client (Delete (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
151 clientWithRoute Proxy req baseurl = do
151 clientWithRoute Proxy req baseurl = do
152 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] baseurl
152 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodDelete req [200, 202] baseurl
153 return $ Headers { getResponse = resp
153 return $ Headers { getResponse = resp
@@ -163,7 +163,7 @@ instance
163 {-# OVERLAPPABLE #-}
163 {-# OVERLAPPABLE #-}
164#endif
164#endif
165 (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
165 (MimeUnrender ct result) => HasClient (Get (ct ': cts) result) where
166− type Client' (Get (ct ': cts) result) = EitherT ServantError IO result
166+ type Client (Get (ct ': cts) result) = EitherT ServantError IO result
167 clientWithRoute Proxy req baseurl =
167 clientWithRoute Proxy req baseurl =
168 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] baseurl
168 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203] baseurl
169
169
@@ -174,7 +174,7 @@ instance
174 {-# OVERLAPPING #-}
174 {-# OVERLAPPING #-}
175#endif
175#endif
176 HasClient (Get (ct ': cts) ()) where
176 HasClient (Get (ct ': cts) ()) where
177− type Client' (Get (ct ': cts) ()) = EitherT ServantError IO ()
177+ type Client (Get (ct ': cts) ()) = EitherT ServantError IO ()
178 clientWithRoute Proxy req baseurl =
178 clientWithRoute Proxy req baseurl =
179 performRequestNoBody H.methodGet req [204] baseurl
179 performRequestNoBody H.methodGet req [204] baseurl
180
180
@@ -186,7 +186,7 @@ instance
186#endif
186#endif
187 ( MimeUnrender ct a, BuildHeadersTo ls
187 ( MimeUnrender ct a, BuildHeadersTo ls
188 ) => HasClient (Get (ct ': cts) (Headers ls a)) where
188 ) => HasClient (Get (ct ': cts) (Headers ls a)) where
189− type Client' (Get (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
189+ type Client (Get (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
190 clientWithRoute Proxy req baseurl = do
190 clientWithRoute Proxy req baseurl = do
191 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203, 204] baseurl
191 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodGet req [200, 203, 204] baseurl
192 return $ Headers { getResponse = resp
192 return $ Headers { getResponse = resp
@@ -221,7 +221,7 @@ instance
221instance (KnownSymbol sym, ToText a, HasClient sublayout)
221instance (KnownSymbol sym, ToText a, HasClient sublayout)
222 => HasClient (Header sym a :> sublayout) where
222 => HasClient (Header sym a :> sublayout) where
223
223
224− type Client' (Header sym a :> sublayout) =
224+ type Client (Header sym a :> sublayout) =
225 Maybe a -> Client sublayout
225 Maybe a -> Client sublayout
226
226
227 clientWithRoute Proxy req baseurl mval =
227 clientWithRoute Proxy req baseurl mval =
@@ -243,7 +243,7 @@ instance
243 {-# OVERLAPPABLE #-}
243 {-# OVERLAPPABLE #-}
244#endif
244#endif
245 (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
245 (MimeUnrender ct a) => HasClient (Post (ct ': cts) a) where
246− type Client' (Post (ct ': cts) a) = EitherT ServantError IO a
246+ type Client (Post (ct ': cts) a) = EitherT ServantError IO a
247 clientWithRoute Proxy req baseurl =
247 clientWithRoute Proxy req baseurl =
248 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPost req [200,201] baseurl
248 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPost req [200,201] baseurl
249
249
@@ -254,7 +254,7 @@ instance
254 {-# OVERLAPPING #-}
254 {-# OVERLAPPING #-}
255#endif
255#endif
256 HasClient (Post (ct ': cts) ()) where
256 HasClient (Post (ct ': cts) ()) where
257− type Client' (Post (ct ': cts) ()) = EitherT ServantError IO ()
257+ type Client (Post (ct ': cts) ()) = EitherT ServantError IO ()
258 clientWithRoute Proxy req baseurl =
258 clientWithRoute Proxy req baseurl =
259 void $ performRequestNoBody H.methodPost req [204] baseurl
259 void $ performRequestNoBody H.methodPost req [204] baseurl
260
260
@@ -266,7 +266,7 @@ instance
266#endif
266#endif
267 ( MimeUnrender ct a, BuildHeadersTo ls
267 ( MimeUnrender ct a, BuildHeadersTo ls
268 ) => HasClient (Post (ct ': cts) (Headers ls a)) where
268 ) => HasClient (Post (ct ': cts) (Headers ls a)) where
269− type Client' (Post (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
269+ type Client (Post (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
270 clientWithRoute Proxy req baseurl = do
270 clientWithRoute Proxy req baseurl = do
271 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPost req [200, 201] baseurl
271 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPost req [200, 201] baseurl
272 return $ Headers { getResponse = resp
272 return $ Headers { getResponse = resp
@@ -282,7 +282,7 @@ instance
282 {-# OVERLAPPABLE #-}
282 {-# OVERLAPPABLE #-}
283#endif
283#endif
284 (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
284 (MimeUnrender ct a) => HasClient (Put (ct ': cts) a) where
285− type Client' (Put (ct ': cts) a) = EitherT ServantError IO a
285+ type Client (Put (ct ': cts) a) = EitherT ServantError IO a
286 clientWithRoute Proxy req baseurl =
286 clientWithRoute Proxy req baseurl =
287 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPut req [200,201] baseurl
287 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPut req [200,201] baseurl
288
288
@@ -293,7 +293,7 @@ instance
293 {-# OVERLAPPING #-}
293 {-# OVERLAPPING #-}
294#endif
294#endif
295 HasClient (Put (ct ': cts) ()) where
295 HasClient (Put (ct ': cts) ()) where
296− type Client' (Put (ct ': cts) ()) = EitherT ServantError IO ()
296+ type Client (Put (ct ': cts) ()) = EitherT ServantError IO ()
297 clientWithRoute Proxy req baseurl =
297 clientWithRoute Proxy req baseurl =
298 void $ performRequestNoBody H.methodPut req [204] baseurl
298 void $ performRequestNoBody H.methodPut req [204] baseurl
299
299
@@ -305,7 +305,7 @@ instance
305#endif
305#endif
306 ( MimeUnrender ct a, BuildHeadersTo ls
306 ( MimeUnrender ct a, BuildHeadersTo ls
307 ) => HasClient (Put (ct ': cts) (Headers ls a)) where
307 ) => HasClient (Put (ct ': cts) (Headers ls a)) where
308− type Client' (Put (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
308+ type Client (Put (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
309 clientWithRoute Proxy req baseurl = do
309 clientWithRoute Proxy req baseurl = do
310 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPut req [200, 201] baseurl
310 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPut req [200, 201] baseurl
311 return $ Headers { getResponse = resp
311 return $ Headers { getResponse = resp
@@ -321,7 +321,7 @@ instance
321 {-# OVERLAPPABLE #-}
321 {-# OVERLAPPABLE #-}
322#endif
322#endif
323 (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
323 (MimeUnrender ct a) => HasClient (Patch (ct ': cts) a) where
324− type Client' (Patch (ct ': cts) a) = EitherT ServantError IO a
324+ type Client (Patch (ct ': cts) a) = EitherT ServantError IO a
325 clientWithRoute Proxy req baseurl =
325 clientWithRoute Proxy req baseurl =
326 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200,201] baseurl
326 snd <$> performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200,201] baseurl
327
327
@@ -332,7 +332,7 @@ instance
332 {-# OVERLAPPING #-}
332 {-# OVERLAPPING #-}
333#endif
333#endif
334 HasClient (Patch (ct ': cts) ()) where
334 HasClient (Patch (ct ': cts) ()) where
335− type Client' (Patch (ct ': cts) ()) = EitherT ServantError IO ()
335+ type Client (Patch (ct ': cts) ()) = EitherT ServantError IO ()
336 clientWithRoute Proxy req baseurl =
336 clientWithRoute Proxy req baseurl =
337 void $ performRequestNoBody H.methodPatch req [204] baseurl
337 void $ performRequestNoBody H.methodPatch req [204] baseurl
338
338
@@ -344,7 +344,7 @@ instance
344#endif
344#endif
345 ( MimeUnrender ct a, BuildHeadersTo ls
345 ( MimeUnrender ct a, BuildHeadersTo ls
346 ) => HasClient (Patch (ct ': cts) (Headers ls a)) where
346 ) => HasClient (Patch (ct ': cts) (Headers ls a)) where
347− type Client' (Patch (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
347+ type Client (Patch (ct ': cts) (Headers ls a)) = EitherT ServantError IO (Headers ls a)
348 clientWithRoute Proxy req baseurl = do
348 clientWithRoute Proxy req baseurl = do
349 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200, 201, 204] baseurl
349 (hdrs, resp) <- performRequestCT (Proxy :: Proxy ct) H.methodPatch req [200, 201, 204] baseurl
350 return $ Headers { getResponse = resp
350 return $ Headers { getResponse = resp
@@ -379,7 +379,7 @@ instance
379instance (KnownSymbol sym, ToText a, HasClient sublayout)
379instance (KnownSymbol sym, ToText a, HasClient sublayout)
380 => HasClient (QueryParam sym a :> sublayout) where
380 => HasClient (QueryParam sym a :> sublayout) where
381
381
382− type Client' (QueryParam sym a :> sublayout) =
382+ type Client (QueryParam sym a :> sublayout) =
383 Maybe a -> Client sublayout
383 Maybe a -> Client sublayout
384
384
385 -- if mparam = Nothing, we don't add it to the query string
385 -- if mparam = Nothing, we don't add it to the query string
@@ -425,7 +425,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
425instance (KnownSymbol sym, ToText a, HasClient sublayout)
425instance (KnownSymbol sym, ToText a, HasClient sublayout)
426 => HasClient (QueryParams sym a :> sublayout) where
426 => HasClient (QueryParams sym a :> sublayout) where
427
427
428− type Client' (QueryParams sym a :> sublayout) =
428+ type Client (QueryParams sym a :> sublayout) =
429 [a] -> Client sublayout
429 [a] -> Client sublayout
430
430
431 clientWithRoute Proxy req baseurl paramlist =
431 clientWithRoute Proxy req baseurl paramlist =
@@ -464,7 +464,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
464instance (KnownSymbol sym, HasClient sublayout)
464instance (KnownSymbol sym, HasClient sublayout)
465 => HasClient (QueryFlag sym :> sublayout) where
465 => HasClient (QueryFlag sym :> sublayout) where
466
466
467− type Client' (QueryFlag sym :> sublayout) =
467+ type Client (QueryFlag sym :> sublayout) =
468 Bool -> Client sublayout
468 Bool -> Client sublayout
469
469
470 clientWithRoute Proxy req baseurl flag =
470 clientWithRoute Proxy req baseurl flag =
@@ -505,7 +505,7 @@ instance (KnownSymbol sym, HasClient sublayout)
505instance (KnownSymbol sym, ToText a, HasClient sublayout)
505instance (KnownSymbol sym, ToText a, HasClient sublayout)
506 => HasClient (MatrixParam sym a :> sublayout) where
506 => HasClient (MatrixParam sym a :> sublayout) where
507
507
508− type Client' (MatrixParam sym a :> sublayout) =
508+ type Client (MatrixParam sym a :> sublayout) =
509 Maybe a -> Client sublayout
509 Maybe a -> Client sublayout
510
510
511 -- if mparam = Nothing, we don't add it to the query string
511 -- if mparam = Nothing, we don't add it to the query string
@@ -550,7 +550,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
550instance (KnownSymbol sym, ToText a, HasClient sublayout)
550instance (KnownSymbol sym, ToText a, HasClient sublayout)
551 => HasClient (MatrixParams sym a :> sublayout) where
551 => HasClient (MatrixParams sym a :> sublayout) where
552
552
553− type Client' (MatrixParams sym a :> sublayout) =
553+ type Client (MatrixParams sym a :> sublayout) =
554 [a] -> Client sublayout
554 [a] -> Client sublayout
555
555
556 clientWithRoute Proxy req baseurl paramlist =
556 clientWithRoute Proxy req baseurl paramlist =
@@ -589,7 +589,7 @@ instance (KnownSymbol sym, ToText a, HasClient sublayout)
589instance (KnownSymbol sym, HasClient sublayout)
589instance (KnownSymbol sym, HasClient sublayout)
590 => HasClient (MatrixFlag sym :> sublayout) where
590 => HasClient (MatrixFlag sym :> sublayout) where
591
591
592− type Client' (MatrixFlag sym :> sublayout) =
592+ type Client (MatrixFlag sym :> sublayout) =
593 Bool -> Client sublayout
593 Bool -> Client sublayout
594
594
595 clientWithRoute Proxy req baseurl flag =
595 clientWithRoute Proxy req baseurl flag =
@@ -605,9 +605,9 @@ instance (KnownSymbol sym, HasClient sublayout)
605-- | Pick a 'Method' and specify where the server you want to query is. You get
605-- | Pick a 'Method' and specify where the server you want to query is. You get
606-- back the full `Response`.
606-- back the full `Response`.
607instance HasClient Raw where
607instance HasClient Raw where
608− type Client' Raw = H.Method -> EitherT ServantError IO (Int, ByteString, MediaType, [HTTP.Header], Response ByteString)
608+ type Client Raw = H.Method -> EitherT ServantError IO (Int, ByteString, MediaType, [HTTP.Header], Response ByteString)
609
609
610− clientWithRoute :: Proxy Raw -> Req -> BaseUrl -> Client' Raw
610+ clientWithRoute :: Proxy Raw -> Req -> BaseUrl -> Client Raw
611 clientWithRoute Proxy req baseurl httpMethod = do
611 clientWithRoute Proxy req baseurl httpMethod = do
612 performRequest httpMethod req (const True) baseurl
612 performRequest httpMethod req (const True) baseurl
613
613
@@ -632,7 +632,7 @@ instance HasClient Raw where
632instance (MimeRender ct a, HasClient sublayout)
632instance (MimeRender ct a, HasClient sublayout)
633 => HasClient (ReqBody (ct ': cts) a :> sublayout) where
633 => HasClient (ReqBody (ct ': cts) a :> sublayout) where
634
634
635− type Client' (ReqBody (ct ': cts) a :> sublayout) =
635+ type Client (ReqBody (ct ': cts) a :> sublayout) =
636 a -> Client sublayout
636 a -> Client sublayout
637
637
638 clientWithRoute Proxy req baseurl body =
638 clientWithRoute Proxy req baseurl body =
@@ -646,7 +646,7 @@ instance (MimeRender ct a, HasClient sublayout)
646
646
647-- | Make the querying function append @path@ to the request path.
647-- | Make the querying function append @path@ to the request path.
648instance (KnownSymbol path, HasClient sublayout) => HasClient (path :> sublayout) where
648instance (KnownSymbol path, HasClient sublayout) => HasClient (path :> sublayout) where
649− type Client' (path :> sublayout) = Client sublayout
649+ type Client (path :> sublayout) = Client sublayout
650
650
651 clientWithRoute Proxy req baseurl =
651 clientWithRoute Proxy req baseurl =
652 clientWithRoute (Proxy :: Proxy sublayout)
652 clientWithRoute (Proxy :: Proxy sublayout)
servant-client/test/Servant/ClientSpec.hs+1−1
@@ -320,7 +320,7 @@ failSpec = withFailServer $ \ baseUrl -> do
320
320
321data WrappedApi where
321data WrappedApi where
322 WrappedApi :: (HasServer api, Server api ~ EitherT ServantErr IO a,
322 WrappedApi :: (HasServer api, Server api ~ EitherT ServantErr IO a,
323− HasClient api, Client' api ~ EitherT ServantError IO ()) =>
323+ HasClient api, Client api ~ EitherT ServantError IO ()) =>
324 Proxy api -> WrappedApi
324 Proxy api -> WrappedApi
325
325
326
326
servant/Setupdeleted

Binary file not shown.