packages feed

composition-tree 0.2.0.3 → 0.2.0.4

raw patch · 3 files changed

+35/−3 lines, 3 filesdep ~QuickCheckdep ~basedep ~doctestPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: QuickCheck, base, doctest

API changes (from Hackage documentation)

Files

Data/Compositions/Internal.hs view
@@ -83,6 +83,21 @@                    , nodeValue :: !a                    } deriving (Show, Eq, Functor) +#if __GLASGOW_HASKELL__ >= 840+instance Semigroup a => Semigroup (Compositions a) where+  (Tree a) <> (Tree b) = Tree (go (reverse a) b)+    where+      go [] ys  = ys+      go ( x : xs) [] = go xs [x]+      go ( x@(Node sx cx vx) : xs) ( y@(Node sy _ vy) : ys)+       = case compare sx sy of+           LT -> go xs (x : y : ys)+           GT -> let Just (l, r) = cx in go (r : l : xs) (y : ys)+           EQ -> go (Node (sx + sy) (Just (x, y)) (vx <> vy)  : xs) ys++instance Monoid a => Monoid (Compositions a) where+  mempty  = Tree []+#else instance (Monoid a) => Monoid (Compositions a) where   mempty  = Tree []   mappend (Tree a) (Tree b) = Tree (go (reverse a) b)@@ -94,6 +109,7 @@            LT -> go xs (x : y : ys)            GT -> let Just (l, r) = cx in go (r : l : xs) (y : ys)            EQ -> go (Node (sx + sy) (Just (x, y)) (vx <> vy)  : xs) ys+#endif  instance Foldable Compositions where   foldMap f = foldMap f . concatMap helper . unwrap
Data/Compositions/Snoc/Internal.hs view
@@ -27,9 +27,17 @@  newtype Flip a = Flip { unflip :: a } deriving (Functor, Eq) +#if __GLASGOW_HASKELL__ >= 840+instance Semigroup a => Semigroup (Flip a) where+  (Flip a) <> (Flip b) = Flip $ a <> b+ instance Monoid a => Monoid (Flip a) where   mempty = Flip mempty+#else+instance Monoid a => Monoid (Flip a) where+  mempty = Flip mempty   mappend (Flip a) (Flip b) = Flip (mappend b a)+#endif  -- | A /compositions list/ or /composition tree/ is a list data type -- where the elements are monoids, and the 'mconcat' of any contiguous sublist can be@@ -57,9 +65,17 @@ -- newtype Compositions a = C { unC :: C.Compositions (Flip a) } deriving (Eq) +#if __GLASGOW_HASKELL__ >= 840+instance Semigroup a => Semigroup (Compositions a) where+  (C a) <> (C b) = C $ b <> a+ instance Monoid a => Monoid (Compositions a) where+  mempyt = C mempty+#else+instance Monoid a => Monoid (Compositions a) where   mempty = C mempty   mappend (C a) (C b) = C $ b <> a+#endif  instance Foldable Compositions where   foldMap f (C x) = foldMap (f . unflip) . reverse $ toList x
composition-tree.cabal view
@@ -1,5 +1,5 @@ name:                composition-tree-version:             0.2.0.3+version:             0.2.0.4 synopsis:            Composition trees for arbitrary monoids. description:         A compositions list or composition tree is a list data type where the elements are monoids, and the mconcat of any contiguous sublist can be computed in logarithmic time. A common use case of this type is in a wiki, version control system, or collaborative editor, where each change or delta would be stored in a list, and it is sometimes necessary to compute the composed delta between any two versions. license:             BSD3@@ -21,12 +21,12 @@                        Data.Compositions.Snoc                        Data.Compositions.Snoc.Internal   other-extensions:    ScopedTypeVariables, DeriveFunctor, GeneralizedNewtypeDeriving-  build-depends:       base >=4.7 && <4.10+  build-depends:       base >=4.7 && <4.12   default-language:    Haskell2010   test-suite             test-comp-tree   type: exitcode-stdio-1.0   main-is: tests.hs-  build-depends: base >= 4.7 && < 4.10, QuickCheck >= 2.7 && < 2.9, composition-tree, doctest >= 0.9 && < 0.12+  build-depends: base >= 4.7 && < 4.12, QuickCheck >= 2.7 && < 2.12, composition-tree, doctest >= 0.9 && < 0.16   default-language:    Haskell2010