@@ -21,36 +21,34 @@ import Servant.Client (ClientM)
21
21
--
22
22
-- Example:
23
23
--
24
- -- @
25
- -- type API
26
- -- = "foo" :> Capture "x" Int :> Get '[JSON] Int
27
- -- :<|> "bar" :> QueryParam "a" Char :> QueryParam "b" String :> Post '[JSON] [Int]
28
- -- :<|> Captre "nested" Int :> NestedAPI
29
- --
30
- -- type NestedAPI
31
- -- = Get '[JSON] String
32
- -- :<|> "baz" :> QueryParam "c" Char :> Post '[JSON] ()
33
- --
34
- -- data APIClient = APIClient
35
- -- { getFoo :: Int -> ClientM Int
36
- -- , postBar :: Maybe Char -> Maybe String -> ClientM [Int]
37
- -- , mkNestedClient :: Int -> NestedClient
38
- -- } deriving GHC.Generic
39
- --
40
- -- instance Generic.SOP.Generic APIClient
41
- -- instance (Client API ~ client) => ClientLike client APIClient
42
- --
43
- -- data NestedClient = NestedClient
44
- -- { getString :: ClientM String
45
- -- , postBaz :: Maybe Char -> ClientM ()
46
- -- } deriving GHC.Generic
47
- --
48
- -- instance Generic.SOP.Generic
49
- -- instance (Client NestedAPI ~ client) => ClientLike client NestedAPI
50
- --
51
- -- mkAPIClient :: APIClient
52
- -- mkAPIClient = mkClient (client (Proxy :: Proxy API))
53
- -- @
24
+ -- > type API
25
+ -- > = "foo" :> Capture "x" Int :> Get '[JSON] Int
26
+ -- > :<|> "bar" :> QueryParam "a" Char :> QueryParam "b" String :> Post '[JSON] [Int]
27
+ -- > :<|> Capture "nested" Int :> NestedAPI
28
+ -- >
29
+ -- > type NestedAPI
30
+ -- > = Get '[JSON] String
31
+ -- > :<|> "baz" :> QueryParam "c" Char :> Post '[JSON] ()
32
+ -- >
33
+ -- > data APIClient = APIClient
34
+ -- > { getFoo :: Int -> ClientM Int
35
+ -- > , postBar :: Maybe Char -> Maybe String -> ClientM [Int]
36
+ -- > , mkNestedClient :: Int -> NestedClient
37
+ -- > } deriving GHC.Generic
38
+ -- >
39
+ -- > instance Generic.SOP.Generic APIClient
40
+ -- > instance (Client API ~ client) => ClientLike client APIClient
41
+ -- >
42
+ -- > data NestedClient = NestedClient
43
+ -- > { getString :: ClientM String
44
+ -- > , postBaz :: Maybe Char -> ClientM ()
45
+ -- > } deriving GHC.Generic
46
+ -- >
47
+ -- > instance Generic.SOP.Generic
48
+ -- > instance (Client NestedAPI ~ client) => ClientLike client NestedClient
49
+ -- >
50
+ -- > mkAPIClient :: APIClient
51
+ -- > mkAPIClient = mkClient (client (Proxy :: Proxy API))
54
52
class ClientLike client custom where
55
53
mkClient :: client -> custom
56
54
default mkClient :: (Generic custom , GClientLikeP client xs , SOP I '[xs ] ~ Rep custom )
0 commit comments