monoid-subclasses 1.1.1 → 1.1.2
raw patch · 6 files changed
+35/−13 lines, 6 filesdep ~base
Dependency ranges changed: base
Files
- CHANGELOG.md +6/−0
- Test/TestMonoidSubclasses.hs +2/−2
- monoid-subclasses.cabal +3/−3
- src/Data/Monoid/Factorial.hs +2/−2
- src/Data/Monoid/GCD.hs +19/−3
- src/Data/Semigroup/Factorial.hs +3/−3
CHANGELOG.md view
@@ -1,3 +1,9 @@+Version 1.1.2+---------------+* CI tests+* Fallback implementation of `stripCommonSuffix @Text` for GHCjs by Jack Kelly+* Fixed documentation bug #31, Factorial laws too strong+ Version 1.1.1 --------------- * Fixed compilation with GHC 8.0.2
Test/TestMonoidSubclasses.hs view
@@ -880,13 +880,13 @@ newtype TestOffsetPositionedString = TestOffsetPositionedString (OffsetPositioned String) deriving (Show, Arbitrary, CoArbitrary,- Semigroup, LeftReductive, LeftCancellative,+ Semigroup, LeftReductive, Monoid, LeftGCDMonoid, MonoidNull, PositiveMonoid, IsString) newtype TestLinePositionedString = TestLinePositionedString (LinePositioned String) deriving (Show, Arbitrary, CoArbitrary,- Semigroup, LeftReductive, LeftCancellative,+ Semigroup, LeftReductive, Monoid, LeftGCDMonoid, MonoidNull, PositiveMonoid, IsString)
monoid-subclasses.cabal view
@@ -1,10 +1,10 @@ Name: monoid-subclasses-Version: 1.1.1+Version: 1.1.2 Cabal-Version: >= 1.10 Build-Type: Simple Synopsis: Subclasses of Monoid Category: Data, Algebra, Text-Tested-with: GHC+Tested-with: GHC==9.0.1, GHC==8.10.4, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2 Description: A hierarchy of subclasses of 'Monoid' together with their instances for all data structures from base, containers, and text packages.@@ -37,7 +37,7 @@ test-suite Main Type: exitcode-stdio-1.0- Build-Depends: base >= 4.11 && < 5,+ Build-Depends: base >= 4.9 && < 5, bytestring >= 0.9 && < 1.0, containers >= 0.5.7.0 && < 0.7, text >= 0.11 && < 1.3, vector >= 0.12 && < 0.13, primes == 0.2.*, QuickCheck >= 2.9 && < 3, quickcheck-instances >= 0.3.12 && <0.4,
src/Data/Monoid/Factorial.hs view
@@ -38,8 +38,8 @@ null, reverse, span, splitAt, take, takeWhile) --- | Class of monoids that can be split into irreducible (/i.e./, atomic or prime) 'factors' in a unique way. Factors of--- a 'Product' are literally its prime factors:+-- | Class of monoids that can be split into irreducible (/i.e./, atomic or prime) 'factors' in a unique way. Note that+-- 'mempty' is not considered a factor. Factors of a 'Product' are literally its prime factors: -- -- prop> factors (Product 12) == [Product 2, Product 2, Product 3] --
src/Data/Monoid/GCD.hs view
@@ -18,7 +18,7 @@ -- -- * 'OverlappingGCDMonoid' -{-# LANGUAGE Haskell2010, FlexibleInstances, Trustworthy #-}+{-# LANGUAGE CPP, Haskell2010, FlexibleInstances, Trustworthy #-} module Data.Monoid.GCD ( GCDMonoid(..),@@ -33,10 +33,12 @@ import qualified Data.ByteString.Unsafe as ByteString import qualified Data.ByteString.Lazy as LazyByteString import qualified Data.Text as Text+import qualified Data.Text.Encoding as TextEncoding import qualified Data.Text.Internal as Internal import qualified Data.Text.Internal.Lazy as LazyInternal import Data.Text.Unsafe (lengthWord16, reverseIter) import qualified Data.Text.Lazy as LazyText+import qualified Data.Text.Lazy.Encoding as LazyEncoding import qualified Data.IntMap as IntMap import qualified Data.IntSet as IntSet import qualified Data.Map as Map@@ -383,15 +385,22 @@ stripCommonPrefix x y = maybe (Text.empty, x, y) id (Text.commonPrefixes x y) -- | @since 1.0--- /O(suffixLength)/+-- /O(suffixLength)/, except on GHCjs where it is /O(m+n)/ instance RightGCDMonoid Text.Text where- stripCommonSuffix x@(Internal.Text xarr xoff xlen) y@(Internal.Text yarr yoff ylen) = go (pred xlen) (pred ylen)+#if !ghcjs_HOST_OS+ stripCommonSuffix x@(Internal.Text xarr xoff xlen) y@(Internal.Text yarr yoff ylen) = go (pred xlen) (pred ylen) where go i j | i >= 0 && j >= 0 && xc == yc = go (i+xd) (j+yd) | otherwise = (Internal.text xarr xoff (succ i), Internal.text yarr yoff (succ j), Internal.text xarr (xoff+i+1) (xlen-i-1)) where (xc, xd) = reverseIter x i (yc, yd) = reverseIter y j+#else+ stripCommonSuffix x y =+ let (xlist, ylist, slist) =+ stripCommonSuffix (TextEncoding.encodeUtf8 x) (TextEncoding.encodeUtf8 y)+ in (TextEncoding.decodeUtf8 xlist, TextEncoding.decodeUtf8 ylist, TextEncoding.decodeUtf8 slist)+#endif -- Lazy Text instances @@ -402,6 +411,7 @@ -- | @since 1.0 -- /O(m+n)/ instance RightGCDMonoid LazyText.Text where+#if !ghcjs_HOST_OS stripCommonSuffix x0 y0 | x0len < y0len = go id y0p id x0 y0s | x0len > y0len = go x0p id id x0s y0@@ -431,3 +441,9 @@ | (x1p, y1p, c1s) <- stripCommonSuffix x y = go (xp . cs . LazyInternal.chunk x1p) (yp . cs . LazyInternal.chunk y1p) (LazyInternal.chunk c1s) xs ys go _ _ _ _ _ = error "impossible"+#else+ stripCommonSuffix x y =+ let (xlist, ylist, slist) =+ stripCommonSuffix (LazyEncoding.encodeUtf8 x) (LazyEncoding.encodeUtf8 y)+ in (LazyEncoding.decodeUtf8 xlist, LazyEncoding.decodeUtf8 ylist, LazyEncoding.decodeUtf8 slist)+#endif
src/Data/Semigroup/Factorial.hs view
@@ -52,9 +52,7 @@ -- -- > maybe id sconcat . nonEmpty . factors == id -- > List.all (\prime-> factors prime == [prime]) . factors--- > factors . reverse == List.reverse . factors -- > primePrefix s == foldr const s s--- > primeSuffix s == primePrefix (reverse s) -- > foldl f a == List.foldl f a . factors -- > foldl' f a == List.foldl' f a . factors -- > foldr f a == List.foldr f a . factors@@ -93,9 +91,11 @@ reverse s = maybe s sconcat (nonEmpty $ List.reverse $ factors s) {-# MINIMAL factors | foldr #-} --- | A subclass of 'Factorial' whose instances satisfy this additional law:+-- | A subclass of 'Factorial' whose instances satisfy the following additional laws: -- -- > factors (a <> b) == factors a <> factors b+-- > factors . reverse == List.reverse . factors+-- > primeSuffix s == primePrefix (reverse s) class Factorial m => StableFactorial m instance Factorial () where