monoid-subclasses 0.4.0.2 → 0.4.0.3
raw patch · 9 files changed
+42/−42 lines, 9 filesdep ~basePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- Data/Monoid/Cancellative.hs +7/−7
- Data/Monoid/Factorial.hs +5/−5
- Data/Monoid/Instances/ByteString/UTF8.hs +1/−1
- Data/Monoid/Instances/Concat.hs +2/−2
- Data/Monoid/Instances/Measured.hs +1/−1
- Data/Monoid/Instances/Positioned.hs +22/−22
- Data/Monoid/Instances/Stateful.hs +1/−1
- Data/Monoid/Textual.hs +2/−2
- monoid-subclasses.cabal +1/−1
Data/Monoid/Cancellative.hs view
@@ -20,13 +20,13 @@ -- All monoid subclasses listed above are for Abelian, /i.e./, commutative or symmetric monoids. Since most practical -- monoids in Haskell are not Abelian, each of the these classes has two symmetric superclasses: -- --- * 'LeftReductiveMonoid' +-- * 'LeftReductiveMonoid' -- --- * 'LeftCancellativeMonoid' +-- * 'LeftCancellativeMonoid' -- --- * 'LeftGCDMonoid' +-- * 'LeftGCDMonoid' -- --- * 'RightReductiveMonoid' +-- * 'RightReductiveMonoid' -- -- * 'RightCancellativeMonoid' -- @@ -542,8 +542,8 @@ instance LeftGCDMonoid ByteString.ByteString where stripCommonPrefix x y = (xp, xs, ByteString.unsafeDrop maxPrefixLength y) where maxPrefixLength = prefixLength 0 (ByteString.length x `min` ByteString.length y)- prefixLength n len | n < len, - ByteString.unsafeIndex x n == ByteString.unsafeIndex y n = + prefixLength n len | n < len,+ ByteString.unsafeIndex x n == ByteString.unsafeIndex y n = prefixLength (succ n) len | otherwise = n (xp, xs) = ByteString.splitAt maxPrefixLength x@@ -577,7 +577,7 @@ instance LeftGCDMonoid LazyByteString.ByteString where stripCommonPrefix x y = (xp, xs, LazyByteString.drop maxPrefixLength y) where maxPrefixLength = prefixLength 0 (LazyByteString.length x `min` LazyByteString.length y)- prefixLength n len | n < len && LazyByteString.index x n == LazyByteString.index y n = + prefixLength n len | n < len && LazyByteString.index x n == LazyByteString.index y n = prefixLength (succ n) len prefixLength n _ = n (xp, xs) = LazyByteString.splitAt maxPrefixLength x
Data/Monoid/Factorial.hs view
@@ -17,9 +17,9 @@ ) where -import Prelude hiding (break, drop, dropWhile, foldl, foldr, length, map, mapM, mapM_, null,+import Prelude hiding (break, drop, dropWhile, foldl, foldl', foldMap, foldr, length, map, mapM, mapM_, null, reverse, span, splitAt, take, takeWhile)- + import Control.Arrow (first) import qualified Control.Monad as Monad import Data.Monoid (Monoid (..), Dual(..), Sum(..), Product(..), Endo(Endo, appEndo))@@ -44,7 +44,7 @@ -- | 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: ----- prop> factors (Product 12) == [Product 2, Product 2, Product 3] +-- prop> factors (Product 12) == [Product 2, Product 2, Product 3] -- -- Factors of a list are /not/ its elements but all its single-item sublists: --@@ -371,9 +371,9 @@ where (x, xs') = LazyByteString.splitAt 1 xs primePrefix = LazyByteString.take 1 primeSuffix x = LazyByteString.drop (LazyByteString.length x - 1) x- splitPrimePrefix x = if LazyByteString.null x then Nothing + splitPrimePrefix x = if LazyByteString.null x then Nothing else Just (LazyByteString.splitAt 1 x)- splitPrimeSuffix x = if LazyByteString.null x then Nothing + splitPrimeSuffix x = if LazyByteString.null x then Nothing else Just (LazyByteString.splitAt (LazyByteString.length x - 1) x) inits = LazyByteString.inits tails = LazyByteString.tails
Data/Monoid/Instances/ByteString/UTF8.hs view
@@ -39,7 +39,7 @@ ) where -import Prelude hiding (any, drop, dropWhile, foldl, foldl1, foldr, foldr1, scanl, scanr, scanl1, scanr1,+import Prelude hiding (any, drop, dropWhile, foldl, foldl1, foldMap, foldr, foldr1, scanl, scanr, scanl1, scanr1, map, concatMap, break, span) import Control.Exception (assert)
Data/Monoid/Instances/Concat.hs view
@@ -14,7 +14,7 @@ ) where -import Prelude hiding (all, any, break, filter, foldl, foldl1, foldr, foldr1, map, concatMap, +import Prelude hiding (all, any, break, filter, foldl, foldl1, foldMap, foldr, foldr1, map, concatMap, length, null, reverse, scanl, scanr, scanl1, scanr1, span, splitAt) import Control.Applicative (Applicative(..)) import Data.Foldable (Foldable)@@ -171,7 +171,7 @@ xp :< xs | k < n -> (Concat (xp <| xsp), xss) | otherwise -> (Concat $ Seq.singleton xpp, Concat (if null xps then xs else xps <| xs)) where k = length xp- (Concat xsp, xss) = splitAt (n - k) (Concat xs) + (Concat xsp, xss) = splitAt (n - k) (Concat xs) (xpp, xps) = splitAt n xp reverse (Concat x) = Concat (fmap reverse $ reverse x)
Data/Monoid/Instances/Measured.hs view
@@ -14,7 +14,7 @@ ) where -import Prelude hiding (all, any, break, filter, foldl, foldl1, foldr, foldr1, map, concatMap, +import Prelude hiding (all, any, break, filter, foldl, foldl1, foldMap, foldr, foldr1, map, concatMap, length, null, reverse, scanl, scanr, scanl1, scanr1, span, splitAt) import Data.Functor ((<$>)) import qualified Data.List as List
Data/Monoid/Instances/Positioned.hs view
@@ -25,7 +25,7 @@ ) where -import Prelude hiding (all, any, break, filter, foldl, foldl1, foldr, foldr1, lines, map, concatMap,+import Prelude hiding (all, any, break, filter, foldl, foldl1, foldMap, foldr, foldr1, lines, map, concatMap, length, null, reverse, scanl, scanr, scanl1, scanr1, span, splitAt) import Control.Applicative (Applicative(..)) import qualified Data.List as List@@ -43,14 +43,14 @@ extract :: p a -> a position :: p a -> Int -data OffsetPositioned m = OffsetPositioned{offset :: !Int, +data OffsetPositioned m = OffsetPositioned{offset :: !Int, -- ^ the current offset extractOffset :: m} -data LinePositioned m = LinePositioned{fullOffset :: !Int, +data LinePositioned m = LinePositioned{fullOffset :: !Int, -- | the current line- line :: !Int, - lineStart :: !Int, + line :: !Int,+ lineStart :: !Int, extractLines :: m} -- | the current column@@ -95,7 +95,7 @@ showsPrec prec (OffsetPositioned pos c) = shows pos . (": " ++) . showsPrec prec c instance Show m => Show (LinePositioned m) where- showsPrec prec (LinePositioned pos l lpos c) = + showsPrec prec (LinePositioned pos l lpos c) = ("Line " ++) . shows l . (", column " ++) . shows (pos - lpos) . (": " ++) . showsPrec prec c instance StableFactorialMonoid m => Monoid (OffsetPositioned m) where@@ -138,7 +138,7 @@ {-# INLINE isPrefixOf #-} {-# INLINE stripPrefix #-} -instance (StableFactorialMonoid m, TextualMonoid m, LeftReductiveMonoid m) => +instance (StableFactorialMonoid m, TextualMonoid m, LeftReductiveMonoid m) => LeftReductiveMonoid (LinePositioned m) where isPrefixOf a b = isPrefixOf (extractLines a) (extractLines b) stripPrefix LinePositioned{extractLines= c1} (LinePositioned p l lpos c2) =@@ -150,7 +150,7 @@ instance (StableFactorialMonoid m, LeftGCDMonoid m) => LeftGCDMonoid (OffsetPositioned m) where commonPrefix (OffsetPositioned p1 c1) (OffsetPositioned p2 c2) = OffsetPositioned (min p1 p2) (commonPrefix c1 c2)- stripCommonPrefix (OffsetPositioned p1 c1) (OffsetPositioned p2 c2) = + stripCommonPrefix (OffsetPositioned p1 c1) (OffsetPositioned p2 c2) = (OffsetPositioned (min p1 p2) prefix, OffsetPositioned (p1 + l) c1', OffsetPositioned (p2 + l) c2') where (prefix, c1', c2') = stripCommonPrefix c1 c2 l = length prefix@@ -166,8 +166,8 @@ let (prefix, c1', c2') = stripCommonPrefix c1 c2 (lines, columns) = linesColumns' prefix len = length prefix- in (if p1 <= p2 then LinePositioned p1 l1 lp1 prefix else LinePositioned p2 l2 lp2 prefix, - LinePositioned (p1 + len) (l1 + lines) (lp1 + len - columns) c1', + in (if p1 <= p2 then LinePositioned p1 l1 lp1 prefix else LinePositioned p2 l2 lp2 prefix,+ LinePositioned (p1 + len) (l1 + lines) (lp1 + len - columns) c1', LinePositioned (p2 + len) (l2 + lines) (lp2 + len - columns) c2') {-# INLINE commonPrefix #-} {-# INLINE stripCommonPrefix #-}@@ -181,17 +181,17 @@ instance (StableFactorialMonoid m, TextualMonoid m, RightReductiveMonoid m) => RightReductiveMonoid (LinePositioned m) where isSuffixOf LinePositioned{extractLines=c1} LinePositioned{extractLines=c2} = isSuffixOf c1 c2- stripSuffix (LinePositioned p l lp c1) LinePositioned{extractLines=c2} = + stripSuffix (LinePositioned p l lp c1) LinePositioned{extractLines=c2} = fmap (LinePositioned p l lp) (stripSuffix c1 c2) {-# INLINE isSuffixOf #-} {-# INLINE stripSuffix #-} instance (StableFactorialMonoid m, RightGCDMonoid m) => RightGCDMonoid (OffsetPositioned m) where- commonSuffix (OffsetPositioned p1 c1) (OffsetPositioned p2 c2) = + commonSuffix (OffsetPositioned p1 c1) (OffsetPositioned p2 c2) = OffsetPositioned (min (p1 + length c1) (p2 + length c2) - length suffix) suffix where suffix = commonSuffix c1 c2- stripCommonSuffix (OffsetPositioned p1 c1) (OffsetPositioned p2 c2) = - (OffsetPositioned p1 c1', OffsetPositioned p2 c2', + stripCommonSuffix (OffsetPositioned p1 c1) (OffsetPositioned p2 c2) =+ (OffsetPositioned p1 c1', OffsetPositioned p2 c2', OffsetPositioned (min (p1 + length c1') (p2 + length c2')) suffix) where (c1', c2', suffix) = stripCommonSuffix c1 c2 {-# INLINE commonSuffix #-}@@ -283,8 +283,8 @@ where f' (a, p, l, lp) c | characterPrefix c == Just '\n' = (f a (LinePositioned p l lp c), succ p, succ l, p) | otherwise = (f a (LinePositioned p l lp c), succ p, l, lp) foldl' f a0 (LinePositioned p0 l0 lp0 c0) = fstOf4 $! Factorial.foldl' f' (a0, p0, l0, lp0) c0- where f' (a, p, l, lp) c = let a' = f a (LinePositioned p l lp c) - in seq a' (if characterPrefix c == Just '\n' + where f' (a, p, l, lp) c = let a' = f a (LinePositioned p l lp c)+ in seq a' (if characterPrefix c == Just '\n' then (a', succ p, succ l, p) else (a', succ p, l, lp)) foldr f a0 (LinePositioned p0 l0 lp0 c0) = Factorial.foldr f' (const3 a0) c0 p0 l0 lp0@@ -294,7 +294,7 @@ length = length . extractLines foldMap f (LinePositioned p0 l0 lp0 c) = appEndo (Factorial.foldMap f' c) (const mempty) p0 l0 lp0 where -- f' :: m -> Endo (Int -> Int -> Int -> m)- f' prime = Endo (\cont p l lp-> f (LinePositioned p l lp prime) + f' prime = Endo (\cont p l lp-> f (LinePositioned p l lp prime) <> if characterPrefix prime == Just '\n' then cont (succ p) (succ l) p else cont (succ p) l lp)@@ -327,7 +327,7 @@ rewrap (prefix, suffix, (p, l, lp)) = (LinePositioned p0 l0 lp0 prefix, LinePositioned p l lp suffix) splitAt n m@(LinePositioned p l lp c) | n <= 0 = (mempty, m) | n >= length c = (m, mempty)- | otherwise = (LinePositioned p l lp prefix, + | otherwise = (LinePositioned p l lp prefix, LinePositioned p' (l + lines) (p' - columns) suffix) where (prefix, suffix) = splitAt n c (lines, columns) = linesColumns prefix@@ -460,7 +460,7 @@ {-# INLINE find #-} instance (StableFactorialMonoid m, TextualMonoid m) => TextualMonoid (LinePositioned m) where- splitCharacterPrefix (LinePositioned p l lp c) = + splitCharacterPrefix (LinePositioned p l lp c) = case splitCharacterPrefix c of Nothing -> Nothing Just ('\n', rest) -> Just ('\n', LinePositioned (succ p) (succ l) p rest)@@ -481,10 +481,10 @@ fc' (a, p, l, _lp) '\n' = (fc a '\n', succ p, succ l, p) fc' (a, p, l, lp) c = (fc a c, succ p, l, lp) foldl' ft fc a0 (LinePositioned p0 l0 lp0 c0) = fstOf4 $ Textual.foldl' ft' fc' (a0, p0, l0, lp0) c0- where ft' (a, p, l, lp) c = let a' = ft a (LinePositioned p l lp c) + where ft' (a, p, l, lp) c = let a' = ft a (LinePositioned p l lp c) p' = succ p in a' `seq` p' `seq` (a', p', l, lp)- fc' (a, p, l, lp) c = let a' = fc a c + fc' (a, p, l, lp) c = let a' = fc a c p' = succ p l' = succ l in a' `seq` p' `seq` if c == '\n'@@ -534,7 +534,7 @@ split f (LinePositioned p0 l0 lp0 c0) = rewrap p0 l0 lp0 (Textual.split f c0) where rewrap _ _ _ [] = []- rewrap p l lp (c:rest) = LinePositioned p l lp c + rewrap p l lp (c:rest) = LinePositioned p l lp c : rewrap p' (l + lines) (if lines == 0 then lp else p' - columns) rest where p' = p + length c (lines, columns) = linesColumns c
Data/Monoid/Instances/Stateful.hs view
@@ -19,7 +19,7 @@ ) where -import Prelude hiding (all, any, break, elem, drop, filter, foldl, foldl1, foldr, foldr1, map, concatMap,+import Prelude hiding (all, any, break, elem, drop, filter, foldl, foldl1, foldMap, foldr, foldr1, map, concatMap, length, null, reverse, scanl, scanr, scanl1, scanr1, span, splitAt, take) import Control.Applicative (Applicative(..)) import Data.Functor ((<$>))
Data/Monoid/Textual.hs view
@@ -302,7 +302,7 @@ scanl = List.scanl scanl1 = List.scanl1 scanr = List.scanr- scanr1 = List.scanr1 + scanr1 = List.scanr1 mapAccumL = List.mapAccumL mapAccumR = List.mapAccumR @@ -365,7 +365,7 @@ scanl = Text.scanl scanl1 = Text.scanl1 scanr = Text.scanr- scanr1 = Text.scanr1 + scanr1 = Text.scanr1 mapAccumL = Text.mapAccumL mapAccumR = Text.mapAccumR
monoid-subclasses.cabal view
@@ -1,5 +1,5 @@ Name: monoid-subclasses-Version: 0.4.0.2+Version: 0.4.0.3 Cabal-Version: >= 1.10 Build-Type: Simple Synopsis: Subclasses of Monoid