semigroups 0.18.0.1 → 0.18.1
raw patch · 3 files changed
+53/−4 lines, 3 filesdep +binarydep +transformersdep ~base
Dependencies added: binary, transformers
Dependency ranges changed: base
Files
- CHANGELOG.markdown +4/−0
- semigroups.cabal +23/−1
- src-ghc7/Data/Semigroup.hs +26/−3
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+0.18.1+------+* Add the missing instance for `Data.Binary.Builder.Builder`.+ 0.18.0.1 -------- * Added support for `base-4.9`
semigroups.cabal view
@@ -1,6 +1,6 @@ name: semigroups category: Algebra, Data, Data Structures, Math-version: 0.18.0.1+version: 0.18.1 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -32,6 +32,14 @@ default: True manual: True +flag binary+ description:+ You can disable the use of the `binary` package using `-f-binary`.+ .+ Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.+ default: True+ manual: True+ flag bytestring description: You can disable the use of the `bytestring` package using `-f-bytestring`.@@ -72,6 +80,14 @@ default: True manual: True +flag transformers+ description:+ You can disable the use of the `transformers` package using `-f-transformers`.+ .+ Disabling this is an unsupported configuration, but it may be useful for accelerating builds in sa ndboxes for expert users.+ default: True+ manual: True+ flag unordered-containers description: You can disable the use of the `unordered-containers` package using `-f-unordered-containers`.@@ -106,6 +122,9 @@ if impl(ghc >= 7.4 && < 7.5) build-depends: ghc-prim + if flag(binary)+ build-depends: binary+ if flag(bytestring) build-depends: bytestring >= 0.9 && < 1 @@ -126,3 +145,6 @@ if flag(hashable) && flag(unordered-containers) build-depends: unordered-containers >= 0.2 && < 0.3++ if flag(transformers)+ build-depends: transformers >= 0.2 && < 0.6
src-ghc7/Data/Semigroup.hs view
@@ -126,6 +126,10 @@ import Data.IntMap (IntMap) #endif +#ifdef MIN_VERSION_binary+import qualified Data.Binary.Builder as Builder+#endif+ #ifdef MIN_VERSION_bytestring import Data.ByteString as Strict import Data.ByteString.Lazy as Lazy@@ -141,6 +145,10 @@ # endif #endif +#if MIN_VERSION_base(4,8,0) || defined(MIN_VERSION_transformers)+import Data.Functor.Identity+#endif+ #if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged) import Data.Proxy #endif@@ -337,7 +345,7 @@ stimes n (Product a) = Product (a ^ n) -- | This is a valid definition of 'stimes' for a 'Monoid'.--- +-- -- Unlike the default definition of 'stimes', it is defined for 0 -- and so it should be preferred where possible. stimesMonoid :: (Integral b, Monoid a) => b -> a -> a@@ -371,7 +379,7 @@ -- When @x <> x = x@, this definition should be preferred, because it -- works in /O(1)/ rather than /O(log n)/. stimesIdempotent :: Integral b => b -> a -> a-stimesIdempotent n x +stimesIdempotent n x | n <= 0 = error "stimesIdempotent: positive multiplier expected" | otherwise = x {-# INLINE stimesIdempotent #-}@@ -787,6 +795,11 @@ -- (==)/XNOR on Bool forms a 'Semigroup', but has no good name +#ifdef MIN_VERSION_binary+instance Semigroup Builder.Builder where+ (<>) = mappend+#endif+ #ifdef MIN_VERSION_bytestring instance Semigroup Strict.ByteString where (<>) = mappend@@ -1007,6 +1020,16 @@ stimes = stimesIdempotentMonoid #endif +#if MIN_VERSION_base(4,8,0) || defined(MIN_VERSION_transformers)+instance Semigroup a => Semigroup (Identity a) where+# ifdef USE_COERCE+ (<>) = coerce ((<>) :: a -> a -> a)+# else+ Identity a <> Identity b = Identity (a <> b)+# endif+ stimes n (Identity a) = Identity (stimes n a)+#endif+ #if MIN_VERSION_base(4,7,0) || defined(MIN_VERSION_tagged) instance Semigroup (Proxy s) where _ <> _ = Proxy@@ -1021,5 +1044,5 @@ # else Tagged a <> Tagged b = Tagged (a <> b) # endif-#endif stimes n (Tagged a) = Tagged (stimes n a)+#endif