yesod-paginator v1.1.0.2 Release Notes
-
Functor
,Foldable
, andTraversable
instances forPages
And so necessarily,
Page
.These work by applying the functions to a
Pages
' currentPage
, which is to apply it to each of thePage
's items. These can be used to extend the data post-pagination; purely viafmap
, or with effect usingtraverse
.pages <- runDB $ do users <- selectPaginated 10 [UserFoo ==. foo] [] -- for :: Pages User -> (User -> t UserWithPosts) -> t (Pages UserWithPosts) for users $ \user -> do posts <- selectList [PostUserId ==. user] [Desc PostCreatedAt, LimitTo 5] pure $ UserWithPosts user posts
Yes, this does encourage
N+1
queries, but the idea is they will not be harmful whenN
is small due to pagination.