-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Framework-agnostic pagination boilerplate
--   
--   Framework-agnostic pagination boilerplate.
@package pagination
@version 0.2.1


-- | Framework-agnostic pagination boilerplate.
module Data.Pagination

-- | Settings that are required to organize data in paginated form.
data Pagination

-- | Create a <a>Pagination</a> value. May throw
--   <a>PaginationException</a>.
mkPagination :: MonadThrow m => Natural -> Natural -> m Pagination

-- | Get page size (maximum number of items on a page) from a
--   <a>Pagination</a>.
pageSize :: Pagination -> Natural

-- | Get page index from a <a>Pagination</a>.
pageIndex :: Pagination -> Natural

-- | Data in the paginated form.
data Paginated a

-- | Create paginated data.
paginate :: (Functor m, Integral n) => Pagination -> Natural -> (n -> n -> m [a]) -> m (Paginated a)

-- | Get subset of items for current page.
paginatedItems :: Paginated a -> [a]

-- | Get <a>Pagination</a> parameters that were used to create this
--   paginated result.
paginatedPagination :: Paginated a -> Pagination

-- | Get the total number of pages in this collection.
paginatedPagesTotal :: Paginated a -> Natural

-- | Get the total number of items in this collection.
paginatedItemsTotal :: Paginated a -> Natural

-- | Test whether there are other pages.
hasOtherPages :: Paginated a -> Bool

-- | Get range of pages to show before and after the current page. This
--   does not necessarily include the first and the last pages (they are
--   supposed to be shown in all cases). Result of the function is always
--   sorted.
pageRange :: Paginated a -> Natural -> NonEmpty Natural

-- | Is there previous page?
hasPrevPage :: Paginated a -> Bool

-- | Is there next page?
hasNextPage :: Paginated a -> Bool

-- | Backward ellipsis appears when page range (pages around current page
--   to jump to) has gap between its beginning and the first page.
backwardEllip :: Paginated a -> Natural -> Bool

-- | Forward ellipsis appears when page range (pages around current page to
--   jump to) has gap between its end and the last page.
forwardEllip :: Paginated a -> Natural -> Bool

-- | Exception indicating various problems when working with paginated
--   data.
data PaginationException

-- | Page size (number of items per page) was zero
ZeroPageSize :: PaginationException

-- | Page index was zero (they start from one)
ZeroPageIndex :: PaginationException
instance GHC.Generics.Generic Data.Pagination.PaginationException
instance Data.Data.Data Data.Pagination.PaginationException
instance GHC.Show.Show Data.Pagination.PaginationException
instance GHC.Classes.Eq Data.Pagination.PaginationException
instance GHC.Base.Functor Data.Pagination.Paginated
instance GHC.Generics.Generic (Data.Pagination.Paginated a)
instance Data.Data.Data a => Data.Data.Data (Data.Pagination.Paginated a)
instance GHC.Show.Show a => GHC.Show.Show (Data.Pagination.Paginated a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Pagination.Paginated a)
instance GHC.Generics.Generic Data.Pagination.Pagination
instance Data.Data.Data Data.Pagination.Pagination
instance GHC.Show.Show Data.Pagination.Pagination
instance GHC.Classes.Eq Data.Pagination.Pagination
instance Control.DeepSeq.NFData Data.Pagination.PaginationException
instance GHC.Exception.Type.Exception Data.Pagination.PaginationException
instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Data.Pagination.Paginated a)
instance Data.Foldable.Foldable Data.Pagination.Paginated
instance Data.Traversable.Traversable Data.Pagination.Paginated
instance Control.DeepSeq.NFData Data.Pagination.Pagination
