Skip to content

Generalize PagedQuery to allow its reuse by preview github APIs #439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GitHub/Data/Request.hs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ instance IReadOnly 'RA where iro = ROA
-- /Note:/ 'Request' is not 'Functor' on purpose.
data GenRequest (mt :: MediaType *) (rw :: RW) a where
Query :: Paths -> QueryString -> GenRequest mt rw a
PagedQuery :: Paths -> QueryString -> FetchCount -> GenRequest mt rw (Vector a)
PagedQuery :: (a ~ t b, Foldable t, Semigroup a) => Paths -> QueryString -> FetchCount -> GenRequest mt rw a

-- | Command
Command
Expand Down
3 changes: 1 addition & 2 deletions src/GitHub/Request.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Text as T
import qualified Data.Text.Encoding as TE
import qualified Data.Vector as V
import qualified Network.HTTP.Client as HTTP
import qualified Network.HTTP.Client.Internal as HTTP

Expand Down Expand Up @@ -242,7 +241,7 @@ executeRequestWithMgrAndRes mgr auth req = runExceptT $ do
performHttpReq httpReq (PagedQuery _ _ l) =
unTagged (performPagedRequest httpLbs' predicate httpReq :: Tagged mt (ExceptT Error IO (HTTP.Response b)))
where
predicate v = lessFetchCount (V.length v) l
predicate v = lessFetchCount (length v) l

performHttpReq httpReq (Command _ _ _) = do
res <- httpLbs' httpReq
Expand Down