How to extract common Servant.Client parameters?
import Protolude
import Servant.API
import Servant.Client
import OpenAlex.Types
type API_URL = Text
apiUrl :: API_URL
apiUrl = "api.openalex.org"
type PageParams =
QueryParam "page" Page
:> QueryParam "per-page" PerPage
:> QueryParam "cursor" Cursor
type OpenAlexAPI =
-- https://api.openalex.org/concepts
"concepts"
-- :> QueryParam "page" Page
-- :> QueryParam "per-page" PerPage
-- :> QueryParam "cursor" Cursor
:> PageParams
-- TODO: filter, search, sort
:> Get '[JSON] (ListOf Concept)
openAlexApi :: Proxy OpenAlexAPI
openAlexApi = Proxy
--concepts :: Maybe Page -> Maybe PerPage -> Maybe Cursor -> ClientM (ListOf Concept)
concepts :: _ -> ClientM (ListOf Concept)
concepts {- :<|> fetch -} = client openAlexApi
@AlfredoDiNapoli could you check if the PageParams
can be factored out?