Hello community, here is the log from the commit of package ghc-mono-traversable for openSUSE:Factory checked in at 2018-05-30 12:10:58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-mono-traversable (Old) and /work/SRC/openSUSE:Factory/.ghc-mono-traversable.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-mono-traversable" Wed May 30 12:10:58 2018 rev:12 rq:607841 version:1.0.8.1 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-mono-traversable/ghc-mono-traversable.changes 2017-04-14 13:38:36.855817229 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-mono-traversable.new/ghc-mono-traversable.changes 2018-05-30 12:26:28.076004919 +0200 @@ -1,0 +2,17 @@ +Mon May 14 17:02:11 UTC 2018 - psim...@suse.com + +- Update mono-traversable to version 1.0.8.1. + * Compat with gauge 0.1 and 0.2 + * Switch to gauge + * Relax constraint on `singleton` to `MonoPointed` + [#156](https://github.com/snoyberg/mono-traversable/issues/156) + * Add `dropPrefix` and `dropSuffix` to `Data.Sequences` [#139](https://github.com/snoyberg/mono-traversable/issues/139) + * Change `sort` implementation [#153](https://github.com/snoyberg/mono-traversable/issues/153) + * Add `mapNonNull` function to `Data.NonNull` [#150](https://github.com/snoyberg/mono-traversable/issues/150) + * Move `oelem` and `onotElem` into the `MonoFoldable` class [#133](https://github.com/snoyberg/mono-traversable/issues/133) + * Change `instance MonoFoldable (Set e)` to `instance Ord e => MonoFoldable (Set e)` + * Add `dropEnd` function to the `IsSequence` class, and a specialized implementation for `Text` + * Add `ensurePrefix` and `ensureSuffix` functions [#141](https://github.com/snoyberg/mono-traversable/pull/141) + * Fix test suite for foldl 1.3 + +------------------------------------------------------------------- Old: ---- mono-traversable-1.0.2.tar.gz New: ---- mono-traversable-1.0.8.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-mono-traversable.spec ++++++ --- /var/tmp/diff_new_pack.E1w3J8/_old 2018-05-30 12:26:28.855978456 +0200 +++ /var/tmp/diff_new_pack.E1w3J8/_new 2018-05-30 12:26:28.859978320 +0200 @@ -1,7 +1,7 @@ # # spec file for package ghc-mono-traversable # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,12 +19,12 @@ %global pkg_name mono-traversable %bcond_with tests Name: ghc-%{pkg_name} -Version: 1.0.2 +Version: 1.0.8.1 Release: 0 Summary: Type classes for mapping, folding, and traversing monomorphic containers License: MIT -Group: Development/Languages/Other -Url: https://hackage.haskell.org/package/%{pkg_name} +Group: Development/Libraries/Haskell +URL: https://hackage.haskell.org/package/%{pkg_name} Source0: https://hackage.haskell.org/package/%{pkg_name}-%{version}/%{pkg_name}-%{version}.tar.gz BuildRequires: ghc-Cabal-devel BuildRequires: ghc-bytestring-devel @@ -37,7 +37,6 @@ BuildRequires: ghc-unordered-containers-devel BuildRequires: ghc-vector-algorithms-devel BuildRequires: ghc-vector-devel -BuildRoot: %{_tmppath}/%{name}-%{version}-build %if %{with tests} BuildRequires: ghc-HUnit-devel BuildRequires: ghc-QuickCheck-devel @@ -47,14 +46,11 @@ %endif %description -Monomorphic variants of the Functor, Foldable, and Traversable typeclasses. -If you understand Haskell's basic typeclasses, you understand mono-traversable. -In addition to what you are used to, it adds on an IsSequence typeclass and has -code for marking data structures as non-empty. +Type classes for mapping, folding, and traversing monomorphic containers. %package devel Summary: Haskell %{pkg_name} library development files -Group: Development/Libraries/Other +Group: Development/Libraries/Haskell Requires: %{name} = %{version}-%{release} Requires: ghc-compiler = %{ghc_version} Requires(post): ghc-compiler = %{ghc_version} @@ -83,11 +79,9 @@ %ghc_pkg_recache %files -f %{name}.files -%defattr(-,root,root,-) -%doc LICENSE +%license LICENSE %files devel -f %{name}-devel.files -%defattr(-,root,root,-) %doc ChangeLog.md README.md %changelog ++++++ mono-traversable-1.0.2.tar.gz -> mono-traversable-1.0.8.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mono-traversable-1.0.2/ChangeLog.md new/mono-traversable-1.0.8.1/ChangeLog.md --- old/mono-traversable-1.0.2/ChangeLog.md 2017-03-02 10:11:36.000000000 +0100 +++ new/mono-traversable-1.0.8.1/ChangeLog.md 2018-01-16 10:37:12.000000000 +0100 @@ -1,3 +1,39 @@ +## 1.0.8.1 + +* Compat with gauge 0.1 and 0.2 + +## 1.0.8.0 + +* Switch to gauge +* Relax constraint on `singleton` to `MonoPointed` + [#156](https://github.com/snoyberg/mono-traversable/issues/156) + +## 1.0.7.0 + +* Add `dropPrefix` and `dropSuffix` to `Data.Sequences` [#139](https://github.com/snoyberg/mono-traversable/issues/139) +* Change `sort` implementation [#153](https://github.com/snoyberg/mono-traversable/issues/153) + +## 1.0.6.0 + +* Add `mapNonNull` function to `Data.NonNull` [#150](https://github.com/snoyberg/mono-traversable/issues/150) + +## 1.0.5.0 + +* Move `oelem` and `onotElem` into the `MonoFoldable` class [#133](https://github.com/snoyberg/mono-traversable/issues/133) + * Change `instance MonoFoldable (Set e)` to `instance Ord e => MonoFoldable (Set e)` + +## 1.0.4.0 + +* Add `dropEnd` function to the `IsSequence` class, and a specialized implementation for `Text` + +## 1.0.3.0 + +* Add `ensurePrefix` and `ensureSuffix` functions [#141](https://github.com/snoyberg/mono-traversable/pull/141) + +## 1.0.2.1 + +* Fix test suite for foldl 1.3 + ## 1.0.2 * `IsSequence` class: add `lengthIndex` [#127](https://github.com/snoyberg/mono-traversable/pull/127) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mono-traversable-1.0.2/bench/sorting.hs new/mono-traversable-1.0.8.1/bench/sorting.hs --- old/mono-traversable-1.0.2/bench/sorting.hs 2016-07-04 09:21:45.000000000 +0200 +++ new/mono-traversable-1.0.8.1/bench/sorting.hs 2018-01-16 10:36:22.000000000 +0100 @@ -1,4 +1,11 @@ -import Criterion.Main +{-# LANGUAGE CPP #-} + +#if MIN_VERSION_gauge(0,2,0) +import Gauge +#else +import Gauge.Main +#endif + import Data.Sequences import Data.MonoTraversable import qualified Data.List diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mono-traversable-1.0.2/mono-traversable.cabal new/mono-traversable-1.0.8.1/mono-traversable.cabal --- old/mono-traversable-1.0.2/mono-traversable.cabal 2017-03-02 10:11:13.000000000 +0100 +++ new/mono-traversable-1.0.8.1/mono-traversable.cabal 2018-01-16 10:39:44.000000000 +0100 @@ -1,75 +1,96 @@ -name: mono-traversable -version: 1.0.2 -synopsis: Type classes for mapping, folding, and traversing monomorphic containers -description: Monomorphic variants of the Functor, Foldable, and Traversable typeclasses. If you understand Haskell's basic typeclasses, you understand mono-traversable. In addition to what you are used to, it adds on an IsSequence typeclass and has code for marking data structures as non-empty. -homepage: https://github.com/snoyberg/mono-traversable -license: MIT -license-file: LICENSE -author: Michael Snoyman, John Wiegley, Greg Weber -maintainer: mich...@snoyman.com -category: Data -build-type: Simple -extra-source-files: README.md - ChangeLog.md -cabal-version: >=1.10 +-- This file has been generated from package.yaml by hpack version 0.20.0. +-- +-- see: https://github.com/sol/hpack +-- +-- hash: 19fd8f1ebe28579b3a09d195725bc11e4c50c0f81206fdfce0513a912a546cf4 + +name: mono-traversable +version: 1.0.8.1 +synopsis: Type classes for mapping, folding, and traversing monomorphic containers +description: Please see the README at <https://www.stackage.org/package/mono-traversable> +category: Data +homepage: https://github.com/snoyberg/mono-traversable#readme +bug-reports: https://github.com/snoyberg/mono-traversable/issues +author: Michael Snoyman, John Wiegley, Greg Weber +maintainer: mich...@snoyman.com +license: MIT +license-file: LICENSE +build-type: Simple +cabal-version: >= 1.10 + +extra-source-files: + ChangeLog.md + README.md + +source-repository head + type: git + location: https://github.com/snoyberg/mono-traversable library + hs-source-dirs: + src ghc-options: -Wall - exposed-modules: Data.MonoTraversable - Data.MonoTraversable.Unprefixed - Data.Containers - Data.Sequences - Data.NonNull - build-depends: base >= 4.7 && < 5 - , containers >= 0.4 - , unordered-containers >=0.2 - , hashable - , bytestring >= 0.9 - , text >=0.11 - , transformers >=0.3 - , vector >=0.10 - , vector-algorithms >= 0.6 - , split >= 0.2 - - if impl(ghc < 8.0) - build-depends: semigroups >= 0.10 - - hs-source-dirs: src - default-language: Haskell2010 + build-depends: + base >=4.7 && <5 + , bytestring >=0.9 + , containers >=0.4 + , hashable + , split >=0.2 + , text >=0.11 + , transformers >=0.3 + , unordered-containers >=0.2 + , vector >=0.10 + , vector-algorithms >=0.6 + if impl(ghc <8.0) + build-depends: + semigroups >=0.10 + exposed-modules: + Data.Containers + Data.MonoTraversable + Data.MonoTraversable.Unprefixed + Data.NonNull + Data.Sequences + other-modules: + Paths_mono_traversable + default-language: Haskell2010 test-suite test - main-is: main.hs - type: exitcode-stdio-1.0 - hs-source-dirs: test - other-modules: Spec - default-language: Haskell2010 - ghc-options: -O0 - build-depends: base - , mono-traversable - , bytestring - , text - , hspec - , HUnit - , transformers - , vector - , QuickCheck - , semigroups - , containers - , unordered-containers - , foldl + type: exitcode-stdio-1.0 + main-is: main.hs + hs-source-dirs: + test + ghc-options: -O0 + build-depends: + HUnit + , QuickCheck + , base + , bytestring + , containers + , foldl + , hspec + , mono-traversable + , semigroups + , text + , transformers + , unordered-containers + , vector + other-modules: + Spec + Paths_mono_traversable + default-language: Haskell2010 benchmark sorting - type: exitcode-stdio-1.0 - hs-source-dirs: bench - build-depends: base - , criterion - , mono-traversable - , vector - , mwc-random - main-is: sorting.hs - ghc-options: -Wall -O2 - default-language: Haskell2010 - -source-repository head - type: git - location: git://github.com/snoyberg/mono-traversable.git + type: exitcode-stdio-1.0 + main-is: sorting.hs + hs-source-dirs: + bench + ghc-options: -Wall -O2 + build-depends: + base + , gauge + , mono-traversable + , mwc-random + , vector + other-modules: + Paths_mono_traversable + default-language: Haskell2010 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mono-traversable-1.0.2/src/Data/MonoTraversable.hs new/mono-traversable-1.0.8.1/src/Data/MonoTraversable.hs --- old/mono-traversable-1.0.2/src/Data/MonoTraversable.hs 2017-02-21 09:04:24.000000000 +0100 +++ new/mono-traversable-1.0.8.1/src/Data/MonoTraversable.hs 2017-12-08 06:59:12.000000000 +0100 @@ -415,6 +415,16 @@ _ -> x {-# INLINE minimumByEx #-} + -- | Checks if the monomorphic container includes the supplied element. + oelem :: Eq (Element mono) => Element mono -> mono -> Bool + oelem e = List.elem e . otoList + {-# INLINE [0] oelem #-} + + -- | Checks if the monomorphic container does not include the supplied element. + onotElem :: Eq (Element mono) => Element mono -> mono -> Bool + onotElem e = List.notElem e . otoList + {-# INLINE [0] onotElem #-} + instance MonoFoldable S.ByteString where ofoldMap f = ofoldr (mappend . f) mempty ofoldr = S.foldr @@ -424,6 +434,8 @@ oany = S.any onull = S.null olength = S.length + oelem = S.elem + onotElem = S.notElem omapM_ f (Unsafe.PS fptr offset len) = do let start = Unsafe.unsafeForeignPtrToPtr fptr `plusPtr` offset @@ -470,6 +482,8 @@ {-# INLINE headEx #-} {-# INLINE lastEx #-} {-# INLINE unsafeHead #-} + {-# INLINE oelem #-} + {-# INLINE onotElem #-} {-# RULES "strict ByteString: ofoldMap = concatMap" ofoldMap = S.concatMap #-} instance MonoFoldable L.ByteString where @@ -486,6 +500,9 @@ ofoldl1Ex' = L.foldl1' headEx = L.head lastEx = L.last + oelem = L.elem + onotElem = L.notElem + {-# INLINE ofoldMap #-} {-# INLINE ofoldr #-} {-# INLINE ofoldl' #-} @@ -499,6 +516,8 @@ {-# INLINE ofoldl1Ex' #-} {-# INLINE headEx #-} {-# INLINE lastEx #-} + {-# INLINE oelem #-} + {-# INLINE onotElem #-} {-# RULES "lazy ByteString: ofoldMap = concatMap" ofoldMap = L.concatMap #-} instance MonoFoldable T.Text where @@ -633,9 +652,13 @@ {-# INLINE unsafeHead #-} {-# INLINE maximumByEx #-} {-# INLINE minimumByEx #-} -instance MonoFoldable (Set e) where +instance Ord e => MonoFoldable (Set e) where olength = Set.size + oelem = Set.member + onotElem = Set.notMember {-# INLINE olength #-} + {-# INLINE oelem #-} + {-# INLINE onotElem #-} instance MonoFoldable (HashSet e) instance U.Unbox a => MonoFoldable (U.Vector a) where @@ -831,25 +854,6 @@ osequence_ = omapM_ id {-# INLINE osequence_ #-} --- | Checks if the monomorphic container includes the supplied element. -oelem :: (MonoFoldable mono, Eq (Element mono)) => Element mono -> mono -> Bool -oelem e = List.elem e . otoList -{-# INLINE [0] oelem #-} - --- | Checks if the monomorphic container does not include the supplied element. -onotElem :: (MonoFoldable mono, Eq (Element mono)) => Element mono -> mono -> Bool -onotElem e = List.notElem e . otoList -{-# INLINE [0] onotElem #-} - -{-# RULES "strict ByteString elem" oelem = S.elem #-} -{-# RULES "strict ByteString notElem" onotElem = S.notElem #-} - -{-# RULES "lazy ByteString elem" oelem = L.elem #-} -{-# RULES "lazy ByteString notElem" oelem = L.notElem #-} - -{-# RULES "Set elem" forall (k :: Ord k => k). oelem k = Set.member k #-} -{-# RULES "Set notElem" forall (k :: Ord k => k). oelem k = Set.notMember k #-} - -- | Get the minimum element of a monomorphic container. -- -- Note: this is a partial function. On an empty 'MonoFoldable', it will diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mono-traversable-1.0.2/src/Data/NonNull.hs new/mono-traversable-1.0.8.1/src/Data/NonNull.hs --- old/mono-traversable-1.0.2/src/Data/NonNull.hs 2016-07-10 16:43:55.000000000 +0200 +++ new/mono-traversable-1.0.8.1/src/Data/NonNull.hs 2017-12-30 19:46:29.000000000 +0100 @@ -36,6 +36,7 @@ , minimumBy , (<|) , toMinList + , mapNonNull , GrowingAppend ) where @@ -348,3 +349,20 @@ -> Element mono minimumBy cmp = minimumByEx cmp . toNullable {-# INLINE minimumBy #-} + +-- | 'fmap' over the underlying container in a 'NonNull'. +-- +-- @since 1.0.6.0 + +-- ==== __Examples__ +-- +-- @ +-- > let xs = 'ncons' 1 [2, 3 :: Int] +-- > 'mapNonNull' 'show' xs +-- 'NonNull' {toNullable = [\"1\",\"2\",\"3\"]} +-- @ +mapNonNull :: (Functor f, MonoFoldable (f b)) + => (a -> b) + -> NonNull (f a) + -> NonNull (f b) +mapNonNull f = impureNonNull . fmap f . toNullable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mono-traversable-1.0.2/src/Data/Sequences.hs new/mono-traversable-1.0.8.1/src/Data/Sequences.hs --- old/mono-traversable-1.0.2/src/Data/Sequences.hs 2017-03-02 10:12:08.000000000 +0100 +++ new/mono-traversable-1.0.8.1/src/Data/Sequences.hs 2018-01-15 19:07:53.000000000 +0100 @@ -8,8 +8,8 @@ -- | Abstractions over sequential data structures, like lists and vectors. module Data.Sequences where -import Data.Maybe (fromJust, isJust) -import Data.Monoid (Monoid, mconcat, mempty) +import Data.Maybe (fromJust, fromMaybe, isJust) +import Data.Monoid (Monoid, mconcat, mempty, (<>)) import Data.MonoTraversable import Data.Int (Int64, Int) import qualified Data.List as List @@ -122,7 +122,7 @@ -- > 'singleton' 'a' :: 'Vector' 'Char' -- 'Data.Vector.fromList' "a" -- @ -singleton :: IsSequence seq => Element seq -> seq +singleton :: MonoPointed seq => Element seq -> seq singleton = opoint {-# INLINE singleton #-} @@ -269,6 +269,19 @@ unsafeDrop :: Index seq -> seq -> seq unsafeDrop = drop + -- | Same as 'drop' but drops from the end of the sequence instead. + -- + -- @ + -- > 'dropEnd' 3 "abcdefg" + -- "abcd" + -- > 'dropEnd' 4 ('fromList' [1,2,3,4,5,6] :: 'Vector' 'Int') + -- fromList [1,2] + -- @ + -- + -- @since 1.0.4.0 + dropEnd :: Index seq -> seq -> seq + dropEnd i s = fst $ splitAt (lengthIndex s - i) s + -- | 'partition' takes a predicate and a sequence and returns the pair of -- sequences of elements which do and do not satisfy the predicate. -- @@ -295,10 +308,10 @@ -- or 'Nothing' if the sequence is empty. -- -- @ - -- > 'uncons' ('fromList' [1,2,3,4] :: 'Vector' 'Int') + -- > 'unsnoc' ('fromList' [1,2,3,4] :: 'Vector' 'Int') -- 'Just' (fromList [1,2,3],4) -- - -- > 'uncons' ([] :: ['Int']) + -- > 'unsnoc' ([] :: ['Int']) -- 'Nothing' -- @ unsnoc :: seq -> Maybe (seq, Element seq) @@ -724,6 +737,7 @@ splitAt = T.splitAt take = T.take drop = T.drop + dropEnd = T.dropEnd partition = T.partition uncons = T.uncons unsnoc t @@ -1222,7 +1236,7 @@ -- -- @ -- > 'stripPrefix' "foo" "foobar" --- 'Just' "foo" +-- 'Just' "bar" -- > 'stripPrefix' "abc" "foobar" -- 'Nothing' -- @ @@ -1246,6 +1260,61 @@ stripSuffixList :: Eq a => [a] -> [a] -> Maybe [a] stripSuffixList x' y' = fmap reverse (stripPrefix (reverse x') (reverse y')) +-- | 'dropPrefix' drops the given prefix from a sequence. It returns the +-- original sequence if the sequence doesn't start with the given prefix. +-- +-- @ +-- > 'dropPrefix' \"foo\" \"foobar\" +-- \"bar\" +-- > 'dropPrefix' \"abc\" \"foobar\" +-- \"foobar\" +-- @ +-- +-- @since 1.0.7.0 +dropPrefix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> seq +dropPrefix x y = fromMaybe y (stripPrefix x y) + +-- | 'dropSuffix' drops the given suffix from a sequence. It returns the +-- original sequence if the sequence doesn't end with the given suffix. +-- +-- @ +-- > 'dropSuffix' \"bar\" \"foobar\" +-- \"foo\" +-- > 'dropSuffix' \"abc\" \"foobar\" +-- \"foobar\" +-- @ +-- +-- @since 1.0.7.0 +dropSuffix :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> seq +dropSuffix x y = fromMaybe y (stripSuffix x y) + +-- | 'ensurePrefix' will add a prefix to a sequence if it doesn't +-- exist, and otherwise have no effect. +-- +-- @ +-- > 'ensurePrefix' "foo" "foobar" +-- "foobar" +-- > 'ensurePrefix' "abc" "foobar" +-- "abcfoobar" +-- @ +-- +-- @since 1.0.3 +ensurePrefix :: (Eq (Element seq), IsSequence seq) => seq -> seq -> seq +ensurePrefix prefix seq = if isPrefixOf prefix seq then seq else prefix <> seq + +-- | Append a suffix to a sequence, unless it already has that suffix. +-- +-- @ +-- > 'ensureSuffix' "bar" "foobar" +-- "foobar" +-- > 'ensureSuffix' "abc" "foobar" +-- "foobarabc" +-- @ +-- +-- @since 1.0.3 +ensureSuffix :: (Eq (Element seq), IsSequence seq) => seq -> seq -> seq +ensureSuffix suffix seq = if isSuffixOf suffix seq then seq else seq <> suffix + -- | 'isPrefixOf' takes two sequences and returns 'True' if the first -- sequence is a prefix of the second. isPrefixOf :: (IsSequence seq, Eq (Element seq)) => seq -> seq -> Bool @@ -1394,8 +1463,8 @@ -- > 'sort' [4,3,1,2] -- [1,2,3,4] -- @ -sort :: (IsSequence seq, Ord (Element seq)) => seq -> seq -sort = fromList . V.toList . vectorSort . V.fromList . otoList +sort :: (SemiSequence seq, Ord (Element seq)) => seq -> seq +sort = sortBy compare {-# INLINE [0] sort #-} {-# RULES "strict ByteString sort" sort = S.sort #-} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mono-traversable-1.0.2/test/Spec.hs new/mono-traversable-1.0.8.1/test/Spec.hs --- old/mono-traversable-1.0.2/test/Spec.hs 2016-09-15 14:28:46.000000000 +0200 +++ new/mono-traversable-1.0.8.1/test/Spec.hs 2018-01-15 11:44:14.000000000 +0100 @@ -3,6 +3,8 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ViewPatterns #-} {-# LANGUAGE CPP #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE PatternSynonyms #-} module Spec where @@ -19,6 +21,7 @@ import Test.Hspec.QuickCheck import Test.HUnit ((@?=)) import Test.QuickCheck hiding (NonEmptyList(..)) +import Test.QuickCheck.Function (pattern Fn) import qualified Test.QuickCheck.Modifiers as QCM import Data.Text (Text) @@ -207,6 +210,15 @@ prop "toMinList" $ \(NonEmpty' ne) -> (NE.toList ne :: [Int]) @?= NN.toNullable (NN.toMinList ne) + describe "mapNonNull" $ do + prop "mapNonNull id == id" $ \x xs -> + let nonNull = NN.ncons x (xs :: [Int]) + in NN.mapNonNull Prelude.id nonNull @?= nonNull + prop "mapNonNull (f . g) == mapNonNull f . mapNonNull g" $ + \(Fn (f :: Integer -> String)) (Fn (g :: Int -> Integer)) x xs -> + let nns = NN.ncons x (xs :: [Int]) + in NN.mapNonNull (f . g) nns @?= NN.mapNonNull f (NN.mapNonNull g nns) + let -- | Type restricted 'NN.ncons' nconsAs :: IsSequence seq => Element seq -> [Element seq] -> seq -> NN.NonNull seq nconsAs x xs _ = NN.ncons x (fromList xs) @@ -367,8 +379,13 @@ describe "Foldl Integration" $ do prop "vector" $ \xs -> do +#if MIN_VERSION_foldl(1,3,0) + let x1 = Foldl.fold Foldl.vector (xs :: [Int]) + x2 = Foldl.purely ofoldlUnwrap Foldl.vector xs +#else x1 <- Foldl.foldM Foldl.vector (xs :: [Int]) x2 <- Foldl.impurely ofoldMUnwrap Foldl.vector xs +#endif x2 @?= (x1 :: V.Vector Int) prop "length" $ \xs -> do let x1 = Foldl.fold Foldl.length (xs :: [Int]) @@ -381,7 +398,7 @@ -- replace random element or any random value with random new value \x list new -> forAll (elements (x:list)) $ \old -> let seq' = fromListAs list dummy - in replaceElem old new seq' @?= omap (\x -> if x == old then new else x) seq' + in replaceElem old new seq' @?= omap (\x' -> if x' == old then new else x') seq' #if MIN_VERSION_QuickCheck(2,8,0) prop "replaceSeq old new === ointercalate new . splitSeq old" $ -- replace random subsequence with random new sequence