semigroups 0.15.2 → 0.15.3
raw patch · 3 files changed
+56/−1 lines, 3 filesdep +deepseq
Dependencies added: deepseq
Files
- semigroups.cabal +12/−1
- src/Data/List/NonEmpty.hs +10/−0
- src/Data/Semigroup.hs +34/−0
semigroups.cabal view
@@ -1,6 +1,6 @@ name: semigroups category: Algebra, Data, Data Structures, Math-version: 0.15.2+version: 0.15.3 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -48,6 +48,14 @@ default: True manual: True +flag deepseq+ description:+ You can disable the use of the `deepseq` package using `-f-deepseq`.+ .+ Disabing this is an unsupported configuration, but it may be useful for accelerating builds in sandboxes for expert users.+ default: True+ manual: True+ flag text description: You can disable the use of the `text` package using `-f-text`.@@ -85,6 +93,9 @@ if flag(containers) build-depends: containers >= 0.3 && < 0.6++ if flag(deepseq)+ build-depends: deepseq >= 1.1 && < 1.4 if flag(text) build-depends: text >= 0.10 && < 2
src/Data/List/NonEmpty.hs view
@@ -120,6 +120,11 @@ ) import Control.Applicative++#ifdef MIN_VERSION_deepseq+import Control.DeepSeq (NFData(..))+#endif+ import Control.Monad #ifdef LANGUAGE_DeriveDataTypeable@@ -175,6 +180,11 @@ type Item (NonEmpty a) = a fromList = fromList toList = toList+#endif++#ifdef MIN_VERSION_deepseq+instance NFData a => NFData (NonEmpty a) where+ rnf (x :| xs) = rnf x `seq` rnf xs #endif length :: NonEmpty a -> Int
src/Data/Semigroup.hs view
@@ -81,6 +81,10 @@ import Data.List.NonEmpty import Numeric.Natural.Internal +#ifdef MIN_VERSION_deepseq+import Control.DeepSeq (NFData(..))+#endif+ #ifdef MIN_VERSION_containers import Data.Sequence (Seq, (><)) import Data.Set (Set)@@ -322,6 +326,11 @@ instance MonadFix Min where mfix f = fix (f . getMin) +#ifdef MIN_VERSION_deepseq+instance NFData a => NFData (Min a) where+ rnf (Min a) = rnf a+#endif+ newtype Max a = Max { getMax :: a } deriving ( Eq, Ord, Show, Read #ifdef LANGUAGE_DeriveDataTypeable@@ -386,6 +395,11 @@ instance MonadFix Max where mfix f = fix (f . getMax) +#ifdef MIN_VERSION_deepseq+instance NFData a => NFData (Max a) where+ rnf (Max a) = rnf a+#endif+ -- | Use @'Option' ('First' a)@ to get the behavior of 'Data.Monoid.First' from @Data.Monoid@. newtype First a = First { getFirst :: a } deriving ( Eq, Ord, Show, Read@@ -448,6 +462,11 @@ instance MonadFix First where mfix f = fix (f . getFirst) +#ifdef MIN_VERSION_deepseq+instance NFData a => NFData (First a) where+ rnf (First a) = rnf a+#endif+ -- | Use @'Option' ('Last' a)@ to get the behavior of 'Data.Monoid.Last' from @Data.Monoid@ newtype Last a = Last { getLast :: a } deriving ( Eq, Ord, Show, Read@@ -510,6 +529,11 @@ instance MonadFix Last where mfix f = fix (f . getLast) +#ifdef MIN_VERSION_deepseq+instance NFData a => NFData (Last a) where+ rnf (Last a) = rnf a+#endif+ -- (==)/XNOR on Bool forms a 'Semigroup', but has no good name #ifdef MIN_VERSION_bytestring@@ -579,6 +603,11 @@ enumFromTo (WrapMonoid a) (WrapMonoid b) = WrapMonoid <$> enumFromTo a b enumFromThenTo (WrapMonoid a) (WrapMonoid b) (WrapMonoid c) = WrapMonoid <$> enumFromThenTo a b c +#ifdef MIN_VERSION_deepseq+instance NFData m => NFData (WrappedMonoid m) where+ rnf (WrapMonoid a) = rnf a+#endif+ -- | Repeat a value @n@ times. -- -- > timesN n a = a <> a <> ... <> a -- using <> (n-1) times@@ -649,6 +678,11 @@ instance Traversable Option where traverse f (Option (Just a)) = Option . Just <$> f a traverse _ (Option Nothing) = pure (Option Nothing)++#ifdef MIN_VERSION_deepseq+instance NFData a => NFData (Option a) where+ rnf (Option a) = rnf a+#endif -- | Fold an 'Option' case-wise, just like 'maybe'. option :: b -> (a -> b) -> Option a -> b