Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c705c34

Browse files
author
Thomas M. DuBuisson
committed
Generalize PagedQuery to allow queries of any foldable semigroup.
1 parent d27b8d2 commit c705c34

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/GitHub/Data/Request.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ instance IReadOnly 'RA where iro = ROA
154154
-- /Note:/ 'Request' is not 'Functor' on purpose.
155155
data GenRequest (mt :: MediaType *) (rw :: RW) a where
156156
Query :: Paths -> QueryString -> GenRequest mt rw a
157-
PagedQuery :: Paths -> QueryString -> FetchCount -> GenRequest mt rw (Vector a)
157+
PagedQuery :: (a ~ t b, Foldable t, Semigroup a) => Paths -> QueryString -> FetchCount -> GenRequest mt rw a
158158

159159
-- | Command
160160
Command

src/GitHub/Request.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ import qualified Data.ByteString as BS
100100
import qualified Data.ByteString.Lazy as LBS
101101
import qualified Data.Text as T
102102
import qualified Data.Text.Encoding as TE
103-
import qualified Data.Vector as V
104103
import qualified Network.HTTP.Client as HTTP
105104
import qualified Network.HTTP.Client.Internal as HTTP
106105

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

247246
performHttpReq httpReq (Command _ _ _) = do
248247
res <- httpLbs' httpReq

0 commit comments

Comments
 (0)