@@ -1,10 +1,11 @@
11module Yoga.Fetch.Om
2− ( class DeriveClient
3− , deriveClient
4− , class DeriveClientFn
5− , deriveClientFn
2+ ( deriveClient
3+ , class DeriveClient
4+ , deriveClientImpl
65 , class DeriveClientRL
76 , deriveClientRL
7+ , class DeriveClientFn
8+ , deriveClientFn
89 , module Yoga.HTTP.API.Route
910 , module Yoga.HTTP.API.Path
1011 , module Yoga.Fetch.Om.Simple
@@ -75,14 +76,23 @@ instance
7576
7677class DeriveClient :: Row Type -> Row Type -> Constraint
7778class DeriveClient routesRow clientsRow | routesRow -> clientsRow where
78− deriveClient :: String -> Proxy (Record routesRow) -> Record clientsRow
79+ deriveClientImpl :: String -> Proxy (Record routesRow) -> Record clientsRow
80+
81+-- | Derive API client functions from route definitions
82+-- |
83+-- | Use a Proxy with a wildcard to avoid repetition:
84+-- | ```purescript
85+-- | api = deriveClient "https://api.example.com" (Proxy :: _ UserAPI)
86+-- | ```
87+deriveClient :: forall routesRow clientsRow. DeriveClient routesRow clientsRow => String -> Proxy (Record routesRow) -> Record clientsRow
88+deriveClient = deriveClientImpl
7989
8090instance
8191 ( RowToList routesRow rl
8292 , DeriveClientRL rl () clientsRow
8393 ) =>
8494 DeriveClient routesRow clientsRow where
85− deriveClient baseUrl _ = deriveClientRL baseUrl (Proxy :: _ rl) {}
95+ deriveClientImpl baseUrl _ = deriveClientRL baseUrl (Proxy :: _ rl) {}
8696
8797class DeriveClientRL :: RowList Type -> Row Type -> Row Type -> Constraint
8898class DeriveClientRL rl acc out | rl acc -> out where