semigroups 0.15.4 → 0.16
raw patch · 2 files changed
+8/−8 lines, 2 filesdep ~nats
Dependency ranges changed: nats
Files
- semigroups.cabal +2/−2
- src/Data/Semigroup.hs +6/−6
semigroups.cabal view
@@ -1,6 +1,6 @@ name: semigroups category: Algebra, Data, Data Structures, Math-version: 0.15.4+version: 0.16 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -83,7 +83,7 @@ build-depends: base >= 2 && < 5,- nats >= 0.1 && < 1+ nats >= 0.1 && < 2 if impl(ghc >= 7.4 && < 7.5) build-depends: ghc-prim
src/Data/Semigroup.hs view
@@ -85,7 +85,7 @@ import Data.Foldable import Data.Traversable import Data.List.NonEmpty-import Numeric.Natural.Internal+import Numeric.Natural #ifdef MIN_VERSION_deepseq import Control.DeepSeq (NFData(..))@@ -170,17 +170,17 @@ -- -- See also 'timesN'. - times1p :: Whole n => n -> a -> a+ times1p :: Natural -> a -> a times1p y0 x0 = f x0 (1 Prelude.+ y0) where f x y | even y = f (x <> x) (y `quot` 2) | y == 1 = x- | otherwise = g (x <> x) (unsafePred y `quot` 2) x+ | otherwise = g (x <> x) (pred y `quot` 2) x g x y z | even y = g (x <> x) (y `quot` 2) z | y == 1 = x <> z- | otherwise = g (x <> x) (unsafePred y `quot` 2) (x <> z)+ | otherwise = g (x <> x) (pred y `quot` 2) (x <> z) {-# INLINE times1p #-} -- | A generalization of 'Data.List.cycle' to an arbitrary 'Semigroup'.@@ -659,9 +659,9 @@ -- > timesN n a = a <> a <> ... <> a -- using <> (n-1) times -- -- Implemented using 'times1p'.-timesN :: (Whole n, Monoid a) => n -> a -> a+timesN :: Monoid a => Natural -> a -> a timesN n x | n == 0 = mempty- | otherwise = unwrapMonoid . times1p (unsafePred n) . WrapMonoid $ x+ | otherwise = unwrapMonoid . times1p (pred n) . WrapMonoid $ x {-# INLINE timesN #-}