packages feed

pagination 0.1.0 → 0.1.1

raw patch · 4 files changed

+17/−13 lines, 4 filesdep ~paginationPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: pagination

API changes (from Hackage documentation)

- Data.Pagination: paginate :: (Monad m, Integral n) => Pagination -> Natural -> (n -> n -> m [a]) -> m (Paginated a)
+ Data.Pagination: paginate :: (Functor m, Integral n) => Pagination -> Natural -> (n -> n -> m [a]) -> m (Paginated a)

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+## Pagination 0.1.1++* Relax constraint of `paginate`. We only need `Functor` here, not `Monad`.+ ## Pagination 0.1.0  * Initial release.
Data/Pagination.hs view
@@ -110,21 +110,21 @@  -- | Create paginated data. -paginate :: (Monad m, Integral n)+paginate :: (Functor m, Integral n)   => Pagination        -- ^ Pagination options   -> Natural           -- ^ Total number of items   -> (n -> n -> m [a])      -- ^ The element producing callback. The function takes arguments:      -- offset and limit.   -> m (Paginated a)   -- ^ The paginated data-paginate (Pagination size index') totalItems f = do-  items <- f (fromIntegral offset) (fromIntegral size)-  return Paginated-    { pgItems      = items-    , pgPagination = Pagination size index-    , pgPagesTotal = totalPages-    , pgItemsTotal = totalItems }+paginate (Pagination size index') totalItems f =+  r <$> f (fromIntegral offset) (fromIntegral size)   where+    r xs = Paginated+      { pgItems      = xs+      , pgPagination = Pagination size index+      , pgPagesTotal = totalPages+      , pgItemsTotal = totalItems }     (whole, rems) = totalItems `quotRem` size     totalPages    = max 1 (whole + if rems == 0 then 0 else 1)     index         = min index' totalPages@@ -163,7 +163,7 @@ -- | Is there previous page?  hasPrevPage :: Paginated a -> Bool-hasPrevPage Paginated {..} = pageIndex pgPagination > (1 :: Natural)+hasPrevPage Paginated {..} = pageIndex pgPagination > 1 {-# INLINE hasPrevPage #-}  -- | Is there next page?
README.md view
@@ -7,7 +7,7 @@ [![Build Status](https://travis-ci.org/mrkkrp/pagination.svg?branch=master)](https://travis-ci.org/mrkkrp/pagination) [![Coverage Status](https://coveralls.io/repos/mrkkrp/pagination/badge.svg?branch=master&service=github)](https://coveralls.io/github/mrkkrp/pagination?branch=master) -The package implements pagination boilerplate in framework-agnostic way.+The package implements pagination boilerplate in a framework-agnostic way.  ## License 
pagination.cabal view
@@ -31,7 +31,7 @@ -- POSSIBILITY OF SUCH DAMAGE.  name:                 pagination-version:              0.1.0+version:              0.1.1 cabal-version:        >= 1.10 license:              BSD3 license-file:         LICENSE.md@@ -43,7 +43,7 @@ synopsis:             Framework-agnostic pagination boilerplate build-type:           Simple description:          Framework-agnostic pagination boilerplate.-extra-source-files:   CHANGELOG.md+extra-doc-files:      CHANGELOG.md                     , README.md  source-repository head@@ -78,7 +78,7 @@                     , QuickCheck       >= 2.4 && < 3.0                     , exceptions       >= 0.6 && < 0.9                     , hspec            >= 2.0 && < 3.0-                    , pagination       >= 0.1.0+                    , pagination       >= 0.1.1    if !impl(ghc >= 8.0)     build-depends:    semigroups       == 0.18.*