phadej · GitHub

I've been greatly enjoying the GitHub package as well as the principled approach when considering new APIs and changes. Users pop up from time to time wanting to use another API and GitHub's insistence that many APIs remain beta for an extended period of time has been an hinderance - the machine-man-preview and shadowcat APIs for example.

Github- style packages can be made to support these APIs - it would be great to benefit from all the rich machinery developed here in the github package when doing so. This PR has one small change that doesn't appear to impact the github package's major Haskell APIs, but helps tremendously with reusing github (package) on some preview github (web service) APIs.

Enough preamble! This pull request relaxes PagedQuery from vector to any semigroup foldable. That is:

PagedQuery   :: Paths -> QueryString -> FetchCount -> GenRequest mt rw (Vector a)

To:

PagedQuery   :: (a ~ t b, Foldable t, Semigroup a) => Paths -> QueryString -> FetchCount -> GenRequest mt rw a

The consumer of PagedQuery already was generalized to Semigroup but the predicate used vector length, so the consumer only needed to drop V. - using foldable length - and everything works as before. That's all that is required for re-use of the pagination machinery for several not-yet-standard APIs.

Read the original on github.com ↗