From 0c79a1a4338cf540399d17866796dcc0a06a7ddb Mon Sep 17 00:00:00 2001 From: Carter Tazio Schonwald Date: Fri, 31 Jan 2020 19:11:23 -0500 Subject: [PATCH 01/14] Forward-port changelog updates from v0.12.1 branch Original commit: e42aaa6f7f933a9eb82f2b3bf78e635d67a3c625 --- changelog.md | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) diff --git a/changelog.md b/changelog.md index c4a77282..037eb7d4 100644 --- a/changelog.md +++ b/changelog.md @@ -9,39 +9,7 @@ Changes in version next * fast rejection short circuiting in eqBy operations * the O2 test suite now has reasonable memory usage on every GHC version, special thanks to Alexey Kuleshevich (@lehins). - * `maximumBy` now behaves like its counterpart in `Data.List` in that if - `maximumBy` has to choose between several elements which could be - considered the maximum, it will now choose the last element (previously, - it would choose the first element). Similarly, `maxIndexBy` will also - now pick the last element if several elements could be considered the - maximum. - -TODO: should this be in the next release - * The role signatures on several `Vector` types were too permissive, so they - have been tightened up: - * The role signature for `Data.Vector.Mutable.MVector` is now - `type role MVector nominal representational` (previously, both arguments - were `phantom`). - * The role signature for `Data.Vector.Primitive.Vector` is now - `type role Vector representational` (previously, it was `phantom`). - * The role signature for `Data.Vector.Storable.Vector` is now - `type role Vector nominal` (previous, it was `phantom`), and the signature - for `Data.Vector.Storable.Mutable.MVector` is now - `type role MVector nominal nominal` (previous, both arguments were - `phantom`). - - We pick `nominal` for the role of the last argument instead of - `representational` since the internal structure of a `Storable` vector - is determined by the `Storable` instance of the element type, and it is - not guaranteed that the `Storable` instances between two - representationally equal types will preserve this internal structure. - One consequence of this choice is that it is no longer possible to - `coerce` between `Storable.Vector a` and `Storable.Vector b` if `a` and - `b` are nominally distinct but representationally equal types. We now - provide `unsafeCoerce{M}Vector` functions in - `Data.Vector.Storable{.Mutable}` to allow this (the onus is on the user - to ensure that no `Storable` invariants are broken when using these - functions). + * The `Mutable` type family is now injective on GHC 8.0 or later. * Using empty `Storable` vectors no longer results in division-by-zero errors. From 359b3aba98d6c910cf42874fad11243a3c72fb03 Mon Sep 17 00:00:00 2001 From: Carter Tazio Schonwald Date: Fri, 31 Jan 2020 19:32:53 -0500 Subject: [PATCH 02/14] demonstrator port from testframework to tasty for the runner --- tests/Boilerplater.hs | 2 +- tests/Main.hs | 4 ++-- tests/Tests/Bundle.hs | 7 +++++-- tests/Tests/Move.hs | 2 +- tests/Tests/Vector.hs | 2 +- tests/Tests/Vector/Boxed.hs | 2 +- tests/Tests/Vector/Primitive.hs | 2 +- tests/Tests/Vector/Property.hs | 7 +++++-- tests/Tests/Vector/Storable.hs | 2 +- tests/Tests/Vector/Unboxed.hs | 3 ++- tests/Tests/Vector/UnitTests.hs | 12 ++++++------ vector.cabal | 12 ++++++------ 12 files changed, 32 insertions(+), 25 deletions(-) diff --git a/tests/Boilerplater.hs b/tests/Boilerplater.hs index 5506209e..406c1c1e 100644 --- a/tests/Boilerplater.hs +++ b/tests/Boilerplater.hs @@ -1,6 +1,6 @@ module Boilerplater where -import Test.Framework.Providers.QuickCheck2 +import Test.Tasty.QuickCheck import Language.Haskell.TH diff --git a/tests/Main.hs b/tests/Main.hs index 66428883..3dc627f5 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -5,10 +5,10 @@ import qualified Tests.Vector.UnitTests import qualified Tests.Bundle import qualified Tests.Move -import Test.Framework (defaultMain) +import Test.Tasty (defaultMain,testGroup) main :: IO () -main = defaultMain $ Tests.Bundle.tests +main = defaultMain $ testGroup "toplevel" $ Tests.Bundle.tests ++ Tests.Vector.tests ++ Tests.Vector.UnitTests.tests ++ Tests.Move.tests diff --git a/tests/Tests/Bundle.hs b/tests/Tests/Bundle.hs index 9ae85b4b..c6386340 100644 --- a/tests/Tests/Bundle.hs +++ b/tests/Tests/Bundle.hs @@ -7,12 +7,15 @@ import qualified Data.Vector.Fusion.Bundle as S import Test.QuickCheck -import Test.Framework -import Test.Framework.Providers.QuickCheck2 +import Test.Tasty +import Test.Tasty.QuickCheck hiding (testProperties) import Text.Show.Functions () import Data.List (foldl', foldl1', unfoldr, find, findIndex) +-- migration from testframework to tasty +type Test = TestTree + #define COMMON_CONTEXT(a) \ VANILLA_CONTEXT(a) diff --git a/tests/Tests/Move.hs b/tests/Tests/Move.hs index 60ea8d33..0c4ee2f1 100644 --- a/tests/Tests/Move.hs +++ b/tests/Tests/Move.hs @@ -1,7 +1,7 @@ module Tests.Move (tests) where import Test.QuickCheck -import Test.Framework.Providers.QuickCheck2 +import Test.Tasty.QuickCheck import Test.QuickCheck.Property (Property(..)) import Utilities () diff --git a/tests/Tests/Vector.hs b/tests/Tests/Vector.hs index fdaa7913..5751db43 100644 --- a/tests/Tests/Vector.hs +++ b/tests/Tests/Vector.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ConstraintKinds #-} module Tests.Vector (tests) where -import Test.Framework (testGroup) +import Test.Tasty (testGroup) import qualified Tests.Vector.Boxed import qualified Tests.Vector.Primitive import qualified Tests.Vector.Storable diff --git a/tests/Tests/Vector/Boxed.hs b/tests/Tests/Vector/Boxed.hs index 18ad65bf..d58b9d73 100644 --- a/tests/Tests/Vector/Boxed.hs +++ b/tests/Tests/Vector/Boxed.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ConstraintKinds #-} module Tests.Vector.Boxed (tests) where -import Test.Framework +import Test.Tasty import qualified Data.Vector import Tests.Vector.Property diff --git a/tests/Tests/Vector/Primitive.hs b/tests/Tests/Vector/Primitive.hs index 5e008fc0..fa1856a7 100644 --- a/tests/Tests/Vector/Primitive.hs +++ b/tests/Tests/Vector/Primitive.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ConstraintKinds #-} module Tests.Vector.Primitive (tests) where -import Test.Framework +import Test.Tasty import qualified Data.Vector.Primitive import Tests.Vector.Property diff --git a/tests/Tests/Vector/Property.hs b/tests/Tests/Vector/Property.hs index 5d474f05..f800b156 100644 --- a/tests/Tests/Vector/Property.hs +++ b/tests/Tests/Vector/Property.hs @@ -20,6 +20,7 @@ module Tests.Vector.Property -- re-exports , Data , Random + ,Test ) where import Boilerplater @@ -35,8 +36,8 @@ import qualified Data.Vector.Fusion.Bundle as S import Test.QuickCheck -import Test.Framework -import Test.Framework.Providers.QuickCheck2 +import Test.Tasty +import Test.Tasty.QuickCheck hiding (testProperties) import Text.Show.Functions () import Data.List @@ -57,6 +58,8 @@ type VanillaContext a = ( Eq a , Show a, Arbitrary a, CoArbitrary a type VectorContext a v = ( Eq (v a), Show (v a), Arbitrary (v a), CoArbitrary (v a) , TestData (v a), Model (v a) ~ [a], EqTest (v a) ~ Property, V.Vector v a) +-- | migration hack for moving from TestFramework to Tasty +type Test = TestTree -- TODO: implement Vector equivalents of list functions for some of the commented out properties -- TODO: test and implement some of these other Prelude functions: diff --git a/tests/Tests/Vector/Storable.hs b/tests/Tests/Vector/Storable.hs index bf71f14a..1d825e5a 100644 --- a/tests/Tests/Vector/Storable.hs +++ b/tests/Tests/Vector/Storable.hs @@ -1,7 +1,7 @@ {-# LANGUAGE ConstraintKinds #-} module Tests.Vector.Storable (tests) where -import Test.Framework +import Test.Tasty import qualified Data.Vector.Storable import Tests.Vector.Property diff --git a/tests/Tests/Vector/Unboxed.hs b/tests/Tests/Vector/Unboxed.hs index 2aa0bf8a..6bb55707 100644 --- a/tests/Tests/Vector/Unboxed.hs +++ b/tests/Tests/Vector/Unboxed.hs @@ -1,11 +1,12 @@ {-# LANGUAGE ConstraintKinds #-} module Tests.Vector.Unboxed (tests) where -import Test.Framework +import Test.Tasty import qualified Data.Vector.Unboxed import Tests.Vector.Property + testGeneralUnboxedVector :: forall a. (CommonContext a Data.Vector.Unboxed.Vector, Data.Vector.Unboxed.Unbox a, Ord a, Data a) => Data.Vector.Unboxed.Vector a -> [Test] testGeneralUnboxedVector dummy = concatMap ($ dummy) [ diff --git a/tests/Tests/Vector/UnitTests.hs b/tests/Tests/Vector/UnitTests.hs index eefb43f5..162b1aae 100644 --- a/tests/Tests/Vector/UnitTests.hs +++ b/tests/Tests/Vector/UnitTests.hs @@ -20,9 +20,9 @@ import Foreign.Ptr import Foreign.Storable import Text.Printf -import Test.Framework -import Test.Framework.Providers.HUnit (testCase) -import Test.HUnit (Assertion, assertBool, (@=?), assertFailure) +import Test.Tasty +import Test.Tasty.HUnit (testCase,Assertion, assertBool, (@=?), assertFailure) +-- import Test.HUnit () newtype Aligned a = Aligned { getAligned :: a } @@ -43,7 +43,7 @@ checkAddressAlignment xs = Storable.unsafeWith xs $ \ptr -> do dummy :: a dummy = undefined -tests :: [Test] +tests :: [TestTree] tests = [ testGroup "Data.Vector.Storable.Vector Alignment" [ testCase "Aligned Double" $ @@ -83,7 +83,7 @@ tests = ] testsSliceOutOfBounds :: - (Show (v Int), Generic.Vector v Int) => (Int -> Int -> v Int -> v Int) -> [Test] + (Show (v Int), Generic.Vector v Int) => (Int -> Int -> v Int -> v Int) -> [TestTree] testsSliceOutOfBounds sliceWith = [ testCase "Negative ix" $ sliceTest sliceWith (-2) 2 xs , testCase "Negative size" $ sliceTest sliceWith 2 (-2) xs @@ -139,7 +139,7 @@ testTakeOutOfMemory takeWith = regression188 :: forall proxy a. (Typeable a, Enum a, Bounded a, Eq a, Show a) - => proxy a -> Test + => proxy a -> TestTree regression188 _ = testCase (show (typeOf (undefined :: a))) $ Vector.fromList [maxBound::a] @=? Vector.enumFromTo maxBound maxBound {-# INLINE regression188 #-} diff --git a/vector.cabal b/vector.cabal index 573c3ad9..9bd7931b 100644 --- a/vector.cabal +++ b/vector.cabal @@ -204,8 +204,8 @@ test-suite vector-tests-O0 hs-source-dirs: tests Build-Depends: base >= 4.5 && < 5, template-haskell, base-orphans >= 0.6, vector, primitive, random, - QuickCheck >= 2.9 && < 2.14 , HUnit, test-framework, - test-framework-hunit, test-framework-quickcheck2, + QuickCheck >= 2.9 && < 2.14 , HUnit, tasty, + tasty-hunit, tasty-quickcheck, transformers >= 0.2.0.0 default-extensions: CPP, @@ -218,7 +218,7 @@ test-suite vector-tests-O0 TypeFamilies, TemplateHaskell - Ghc-Options: -O0 + Ghc-Options: -O0 -threaded Ghc-Options: -Wall if !flag(Wall) @@ -247,8 +247,8 @@ test-suite vector-tests-O2 hs-source-dirs: tests Build-Depends: base >= 4.5 && < 5, template-haskell, base-orphans >= 0.6, vector, primitive, random, - QuickCheck >= 2.9 && < 2.14 , HUnit, test-framework, - test-framework-hunit, test-framework-quickcheck2, + QuickCheck >= 2.9 && < 2.14 , HUnit, tasty, + tasty-hunit, tasty-quickcheck, transformers >= 0.2.0.0 default-extensions: CPP, @@ -262,7 +262,7 @@ test-suite vector-tests-O2 TemplateHaskell Ghc-Options: -Wall - Ghc-Options: -O2 + Ghc-Options: -O2 -threaded if !flag(Wall) Ghc-Options: -fno-warn-orphans -fno-warn-missing-signatures if impl(ghc >= 8.0) && impl(ghc < 8.1) From a1e014ec709cfa3f39ec49f95c111e8cea7dec30 Mon Sep 17 00:00:00 2001 From: Carter Tazio Schonwald Date: Fri, 31 Jan 2020 21:10:51 -0500 Subject: [PATCH 03/14] improve the markdown and remove a dead flag from cabal --- changelog.md | 36 +++++++++++++++++------------------- vector.cabal | 1 - 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/changelog.md b/changelog.md index 037eb7d4..1d3f7493 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,4 @@ -Changes in version next - +# Changes in version 0.12.1.0 * Fix integer overflows in specializations of Bundle/Stream enumFromTo on Integral types * Fix possibility of OutOfMemory with `take` and very large arguments. * Fix `slice` function causing segfault and not checking the bounds properly. @@ -9,7 +8,6 @@ Changes in version next * fast rejection short circuiting in eqBy operations * the O2 test suite now has reasonable memory usage on every GHC version, special thanks to Alexey Kuleshevich (@lehins). - * The `Mutable` type family is now injective on GHC 8.0 or later. * Using empty `Storable` vectors no longer results in division-by-zero errors. @@ -21,10 +19,10 @@ Changes in version next `All`, `Alt`, and `Compose`. * Add `NFData1` instances for applicable `Vector` types. -Changes in version 0.12.0.3 +#Changes in version 0.12.0.3 * Monad Fail support -Changes in version 0.12.0.2 +#Changes in version 0.12.0.2 * Fixes issue #220, compact heap operations crashing on boxed vectors constructed using traverse. * backport injective type family support @@ -32,12 +30,12 @@ Changes in version 0.12.0.2 compatible with future Primitive releases -Changes in version 0.12.0.1 +#Changes in version 0.12.0.1 * Make sure `length` can be inlined * Include modules that test-suites depend on in other-modules -Changes in version 0.12.0.0 +#Changes in version 0.12.0.0 * Documentation fixes/additions * New functions: createT, iscanl/r, iterateNM, unfoldrM, uniq @@ -49,7 +47,7 @@ Changes in version 0.12.0.0 helper functions. * Relax context for `Unbox (Complex a)`. -Changes in version 0.11.0.0 +#Changes in version 0.11.0.0 * Define `Applicative` instances for `Data.Vector.Fusion.Util.{Box,Id}` * Define non-bottom `fail` for `instance Monad Vector` @@ -59,50 +57,50 @@ Changes in version 0.11.0.0 - Memory is initialized on creation of unboxed vectors * Changes to SPEC usage to allow building under more conditions -Changes in version 0.10.12.3 +#Changes in version 0.10.12.3 * Allow building with `primtive-0.6` -Changes in version 0.10.12.2 +#Changes in version 0.10.12.2 * Add support for `deepseq-1.4.0.0` -Changes in version 0.10.12.1 +#Changes in version 0.10.12.1 * Fixed compilation on non-head GHCs -Changes in version 0.10.12.0 +#Changes in version 0.10.12.0 * Export MVector constructor from Data.Vector.Primitive to match Vector's (which was already exported). * Fix building on GHC 7.9 by adding Applicative instances for Id and Box -Changes in version 0.10.11.0 +#Changes in version 0.10.11.0 * Support OverloadedLists for boxed Vector in GHC >= 7.8 -Changes in version 0.10.10.0 +#Changes in version 0.10.10.0 * Minor version bump to rectify PVP violation occured in 0.10.9.3 release -Changes in version 0.10.9.3 (deprecated) +#Changes in version 0.10.9.3 (deprecated) * Add support for OverloadedLists in GHC >= 7.8 -Changes in version 0.10.9.2 +#Changes in version 0.10.9.2 * Fix compilation with GHC 7.9 -Changes in version 0.10.9.1 +#Changes in version 0.10.9.1 * Implement poly-kinded Typeable -Changes in version 0.10.0.1 +#Changes in version 0.10.0.1 * Require `primitive` to include workaround for a GHC array copying bug -Changes in version 0.10 +#Changes in version 0.10 * `NFData` instances * More efficient block fills diff --git a/vector.cabal b/vector.cabal index 9bd7931b..8e515735 100644 --- a/vector.cabal +++ b/vector.cabal @@ -99,7 +99,6 @@ Flag Wall Manual: True - Library Default-Language: Haskell2010 Other-Extensions: From 5db999547a85dd32ec32f6a5d941398a1f62fe4e Mon Sep 17 00:00:00 2001 From: Carter Tazio Schonwald Date: Fri, 31 Jan 2020 21:52:34 -0500 Subject: [PATCH 04/14] add semigroups to test suite as dep so CI works on ghc < 8 --- changelog.md | 3 +++ vector.cabal | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 1d3f7493..b6cc9c35 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +# Changes in version 0.12.1.1 + * add semigrioups dep to test suite so CI actually runs again on GHC < 8 + # Changes in version 0.12.1.0 * Fix integer overflows in specializations of Bundle/Stream enumFromTo on Integral types * Fix possibility of OutOfMemory with `take` and very large arguments. diff --git a/vector.cabal b/vector.cabal index 8e515735..3b796e17 100644 --- a/vector.cabal +++ b/vector.cabal @@ -205,7 +205,7 @@ test-suite vector-tests-O0 primitive, random, QuickCheck >= 2.9 && < 2.14 , HUnit, tasty, tasty-hunit, tasty-quickcheck, - transformers >= 0.2.0.0 + transformers >= 0.2.0.0,semigroups default-extensions: CPP, ScopedTypeVariables, @@ -248,7 +248,7 @@ test-suite vector-tests-O2 primitive, random, QuickCheck >= 2.9 && < 2.14 , HUnit, tasty, tasty-hunit, tasty-quickcheck, - transformers >= 0.2.0.0 + transformers >= 0.2.0.0,semigroups default-extensions: CPP, ScopedTypeVariables, From f3f127dd8a17cb1ec9545c1a2e0ce78af9f79b16 Mon Sep 17 00:00:00 2001 From: Carter Tazio Schonwald Date: Sat, 1 Feb 2020 14:49:32 -0500 Subject: [PATCH 05/14] Bring back `mkType` function. Fix #287 Also: * Bump up the version in cabal and update changelog. * Fix markdown header formatting in changelog. --- Data/Vector/Generic.hs | 19 ++++++++++++++++--- changelog.md | 41 ++++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/Data/Vector/Generic.hs b/Data/Vector/Generic.hs index d603bc30..51baab17 100644 --- a/Data/Vector/Generic.hs +++ b/Data/Vector/Generic.hs @@ -165,7 +165,7 @@ module Data.Vector.Generic ( liftShowsPrec, liftReadsPrec, -- ** @Data@ and @Typeable@ - gfoldl, gunfold, dataCast, mkVecType, mkVecConstr + gfoldl, gunfold, dataCast, mkVecType, mkVecConstr, mkType ) where import Data.Vector.Generic.Base @@ -212,10 +212,19 @@ import Data.Typeable ( Typeable1, gcast1 ) #include "vector.h" import Data.Data ( Data, DataType, Constr, Fixity(Prefix), - mkDataType, mkConstr, constrIndex ) - + mkDataType, mkConstr, constrIndex, +#if MIN_VERSION_base(4,2,0) + mkNoRepType ) +#else + mkNorepType ) +#endif import qualified Data.Traversable as T (Traversable(mapM)) +#if !MIN_VERSION_base(4,2,0) +mkNoRepType :: String -> DataType +mkNoRepType = mkNorepType +#endif + -- Length information -- ------------------ @@ -2209,6 +2218,10 @@ mkVecType :: String -> DataType {-# INLINE mkVecType #-} mkVecType name = mkDataType name [mkVecConstr name] +mkType :: String -> DataType +{-# INLINE mkType #-} +mkType = mkNoRepType + gunfold :: (Vector v a, Data a) => (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) diff --git a/changelog.md b/changelog.md index b6cc9c35..6ca86120 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,11 @@ -# Changes in version 0.12.1.1 +# Changes in version 0.12.1.2 + + * Fix for lost function `Data.Vector.Generic.mkType`: [#287](https://github.com/haskell/vector/issues/287) + +# Changes in version 0.12.1.1 (deprecated) * add semigrioups dep to test suite so CI actually runs again on GHC < 8 -# Changes in version 0.12.1.0 +# Changes in version 0.12.1.0 (deprecated) * Fix integer overflows in specializations of Bundle/Stream enumFromTo on Integral types * Fix possibility of OutOfMemory with `take` and very large arguments. * Fix `slice` function causing segfault and not checking the bounds properly. @@ -22,23 +26,22 @@ `All`, `Alt`, and `Compose`. * Add `NFData1` instances for applicable `Vector` types. -#Changes in version 0.12.0.3 +# Changes in version 0.12.0.3 * Monad Fail support -#Changes in version 0.12.0.2 +# Changes in version 0.12.0.2 * Fixes issue #220, compact heap operations crashing on boxed vectors constructed using traverse. * backport injective type family support * Cleanup the memset code internal to storable vector modules to be compatible with future Primitive releases - -#Changes in version 0.12.0.1 +# Changes in version 0.12.0.1 * Make sure `length` can be inlined * Include modules that test-suites depend on in other-modules -#Changes in version 0.12.0.0 +# Changes in version 0.12.0.0 * Documentation fixes/additions * New functions: createT, iscanl/r, iterateNM, unfoldrM, uniq @@ -50,7 +53,7 @@ helper functions. * Relax context for `Unbox (Complex a)`. -#Changes in version 0.11.0.0 +# Changes in version 0.11.0.0 * Define `Applicative` instances for `Data.Vector.Fusion.Util.{Box,Id}` * Define non-bottom `fail` for `instance Monad Vector` @@ -60,50 +63,50 @@ - Memory is initialized on creation of unboxed vectors * Changes to SPEC usage to allow building under more conditions -#Changes in version 0.10.12.3 +# Changes in version 0.10.12.3 * Allow building with `primtive-0.6` -#Changes in version 0.10.12.2 +# Changes in version 0.10.12.2 * Add support for `deepseq-1.4.0.0` -#Changes in version 0.10.12.1 +# Changes in version 0.10.12.1 * Fixed compilation on non-head GHCs -#Changes in version 0.10.12.0 +# Changes in version 0.10.12.0 * Export MVector constructor from Data.Vector.Primitive to match Vector's (which was already exported). * Fix building on GHC 7.9 by adding Applicative instances for Id and Box -#Changes in version 0.10.11.0 +# Changes in version 0.10.11.0 * Support OverloadedLists for boxed Vector in GHC >= 7.8 -#Changes in version 0.10.10.0 +# Changes in version 0.10.10.0 * Minor version bump to rectify PVP violation occured in 0.10.9.3 release -#Changes in version 0.10.9.3 (deprecated) +# Changes in version 0.10.9.3 (deprecated) * Add support for OverloadedLists in GHC >= 7.8 -#Changes in version 0.10.9.2 +# Changes in version 0.10.9.2 * Fix compilation with GHC 7.9 -#Changes in version 0.10.9.1 +# Changes in version 0.10.9.1 * Implement poly-kinded Typeable -#Changes in version 0.10.0.1 +# Changes in version 0.10.0.1 * Require `primitive` to include workaround for a GHC array copying bug -#Changes in version 0.10 +# Changes in version 0.10 * `NFData` instances * More efficient block fills From 06f003437af171212d666581878ac18a2ac318a4 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sat, 11 Apr 2020 13:59:41 +0300 Subject: [PATCH 06/14] We don't support base<4.2 (GHC<6.12) anyway --- Data/Vector/Generic.hs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Data/Vector/Generic.hs b/Data/Vector/Generic.hs index 51baab17..02147c08 100644 --- a/Data/Vector/Generic.hs +++ b/Data/Vector/Generic.hs @@ -212,19 +212,9 @@ import Data.Typeable ( Typeable1, gcast1 ) #include "vector.h" import Data.Data ( Data, DataType, Constr, Fixity(Prefix), - mkDataType, mkConstr, constrIndex, -#if MIN_VERSION_base(4,2,0) - mkNoRepType ) -#else - mkNorepType ) -#endif + mkDataType, mkConstr, constrIndex, mkNoRepType ) import qualified Data.Traversable as T (Traversable(mapM)) -#if !MIN_VERSION_base(4,2,0) -mkNoRepType :: String -> DataType -mkNoRepType = mkNorepType -#endif - -- Length information -- ------------------ From 6e4c9fda6126735f9b48ef57f5ce20abada1e5e3 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sat, 11 Apr 2020 16:51:33 +0300 Subject: [PATCH 07/14] Deprecate mkType instead --- Data/Vector/Generic.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/Data/Vector/Generic.hs b/Data/Vector/Generic.hs index 02147c08..c404065c 100644 --- a/Data/Vector/Generic.hs +++ b/Data/Vector/Generic.hs @@ -2210,6 +2210,7 @@ mkVecType name = mkDataType name [mkVecConstr name] mkType :: String -> DataType {-# INLINE mkType #-} +{-# DEPRECATE mkType "Use Data.Data.mkNoRepType: #-} mkType = mkNoRepType gunfold :: (Vector v a, Data a) From 27cc645971b7251c919e75cfccfc2d76ec31e9d4 Mon Sep 17 00:00:00 2001 From: Carter Tazio Schonwald Date: Fri, 31 Jan 2020 21:08:35 -0500 Subject: [PATCH 08/14] fixup changelog inclusion in extra files and pin down the list vs vector semantics with semigroups code --- tests/Tests/Vector/Property.hs | 40 ++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/tests/Tests/Vector/Property.hs b/tests/Tests/Vector/Property.hs index f800b156..4865cb6c 100644 --- a/tests/Tests/Vector/Property.hs +++ b/tests/Tests/Vector/Property.hs @@ -41,7 +41,8 @@ import Test.Tasty.QuickCheck hiding (testProperties) import Text.Show.Functions () import Data.List -import Data.Monoid + + import qualified Control.Applicative as Applicative import System.Random (Random) @@ -52,6 +53,9 @@ import Control.Monad.Zip import Data.Data +import qualified Data.List.NonEmpty as DLE +import Data.Semigroup (Semigroup(..)) + type CommonContext a v = (VanillaContext a, VectorContext a v) type VanillaContext a = ( Eq a , Show a, Arbitrary a, CoArbitrary a , TestData a, Model a ~ a, EqTest a ~ Property) @@ -517,22 +521,50 @@ testOrdFunctions _ = $(testProperties 'prop_maximum, 'prop_minimum, 'prop_minIndex, 'prop_maxIndex, 'prop_maximumBy, 'prop_minimumBy, - 'prop_maxIndexBy, 'prop_minIndexBy]) + 'prop_maxIndexBy, 'prop_minIndexBy, + 'prop_ListLastMaxIndexWins ]) where prop_compare :: P (v a -> v a -> Ordering) = compare `eq` compare prop_maximum :: P (v a -> a) = not . V.null ===> V.maximum `eq` maximum prop_minimum :: P (v a -> a) = not . V.null ===> V.minimum `eq` minimum prop_minIndex :: P (v a -> Int) = not . V.null ===> V.minIndex `eq` minIndex - prop_maxIndex :: P (v a -> Int) = not . V.null ===> V.maxIndex `eq` maxIndex + prop_maxIndex :: P (v a -> Int) = not . V.null ===> V.maxIndex `eq` listMaxIndexFMW prop_maximumBy :: P (v a -> a) = not . V.null ===> V.maximumBy compare `eq` maximum prop_minimumBy :: P (v a -> a) = not . V.null ===> V.minimumBy compare `eq` minimum prop_maxIndexBy :: P (v a -> Int) = - not . V.null ===> V.maxIndexBy compare `eq` maxIndex + not . V.null ===> V.maxIndexBy compare `eq` listMaxIndexFMW + --- (maxIndex) + prop_ListLastMaxIndexWins :: P (v a -> Int) = + not . V.null ===> ( maxIndex . V.toList) `eq` listMaxIndexLMW + prop_FalseListFirstMaxIndexWinsDesc :: P (v a -> Int) = + (\x -> not $ V.null x && (V.uniq x /= x ) )===> ( maxIndex . V.toList) `eq` listMaxIndexFMW + prop_FalseListFirstMaxIndexWins :: Property + prop_FalseListFirstMaxIndexWins = expectFailure prop_FalseListFirstMaxIndexWinsDesc prop_minIndexBy :: P (v a -> Int) = not . V.null ===> V.minIndexBy compare `eq` minIndex +listMaxIndexFMW :: Ord a => [a] -> Int +listMaxIndexFMW = ( fst . extractFMW . sconcat . DLE.fromList . fmap FMW . zip [0 :: Int ..]) + +listMaxIndexLMW :: Ord a => [a] -> Int +listMaxIndexLMW = ( fst . extractLMW . sconcat . DLE.fromList . fmap LMW . zip [0 :: Int ..]) + +newtype LastMaxWith a i = LMW {extractLMW:: (i,a)} + deriving(Eq,Show,Read) +instance (Ord a) => Semigroup (LastMaxWith a i) where + (<>) x y | snd (extractLMW x) > snd (extractLMW y) = x + | snd (extractLMW x) < snd (extractLMW y) = y + | otherwise = y +newtype FirstMaxWith a i = FMW {extractFMW:: (i,a)} + deriving(Eq,Show,Read) +instance (Ord a) => Semigroup (FirstMaxWith a i) where + (<>) x y | snd (extractFMW x) > snd (extractFMW y) = x + | snd (extractFMW x) < snd (extractFMW y) = y + | otherwise = x + + testEnumFunctions :: forall a v. (CommonContext a v, Enum a, Ord a, Num a, Random a) => v a -> [Test] {-# INLINE testEnumFunctions #-} testEnumFunctions _ = $(testProperties From 6c25f1ede41c3c2c10ebd5886187a3f1bfa5d0a3 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sat, 11 Apr 2020 17:04:56 +0300 Subject: [PATCH 09/14] Add changelog note --- changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/changelog.md b/changelog.md index 6ca86120..55529356 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +# Changes in NEXT_VERSION + + * `mkType` from `Data.Vector.Generic` is deprecated in favor of + `Data.Data.mkNoRepType` + # Changes in version 0.12.1.2 * Fix for lost function `Data.Vector.Generic.mkType`: [#287](https://github.com/haskell/vector/issues/287) From 00ffc50f746acf98e0d5894f1fc7a5637acfd978 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sat, 11 Apr 2020 17:05:32 +0300 Subject: [PATCH 10/14] Restore removed changelog entries --- changelog.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/changelog.md b/changelog.md index 55529356..0342fc6f 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,37 @@ * `mkType` from `Data.Vector.Generic` is deprecated in favor of `Data.Data.mkNoRepType` + * `maximumBy` now behaves like its counterpart in `Data.List` in that if + `maximumBy` has to choose between several elements which could be + considered the maximum, it will now choose the last element (previously, + it would choose the first element). Similarly, `maxIndexBy` will also + now pick the last element if several elements could be considered the + maximum. + * The role signatures on several `Vector` types were too permissive, so they + have been tightened up: + * The role signature for `Data.Vector.Mutable.MVector` is now + `type role MVector nominal representational` (previously, both arguments + were `phantom`). + * The role signature for `Data.Vector.Primitive.Vector` is now + `type role Vector representational` (previously, it was `phantom`). + * The role signature for `Data.Vector.Storable.Vector` is now + `type role Vector nominal` (previous, it was `phantom`), and the signature + for `Data.Vector.Storable.Mutable.MVector` is now + `type role MVector nominal nominal` (previous, both arguments were + `phantom`). + + We pick `nominal` for the role of the last argument instead of + `representational` since the internal structure of a `Storable` vector + is determined by the `Storable` instance of the element type, and it is + not guaranteed that the `Storable` instances between two + representationally equal types will preserve this internal structure. + One consequence of this choice is that it is no longer possible to + `coerce` between `Storable.Vector a` and `Storable.Vector b` if `a` and + `b` are nominally distinct but representationally equal types. We now + provide `unsafeCoerce{M}Vector` functions in + `Data.Vector.Storable{.Mutable}` to allow this (the onus is on the user + to ensure that no `Storable` invariants are broken when using these + functions). # Changes in version 0.12.1.2 From 2a73fb4887b89af0429896a25b264c616875e5e4 Mon Sep 17 00:00:00 2001 From: Carter Tazio Schonwald Date: Fri, 31 Jan 2020 22:10:21 -0500 Subject: [PATCH 11/14] make sure the semantics checker for maxIndex runs --- tests/Tests/Vector/Property.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tests/Vector/Property.hs b/tests/Tests/Vector/Property.hs index 4865cb6c..448f83de 100644 --- a/tests/Tests/Vector/Property.hs +++ b/tests/Tests/Vector/Property.hs @@ -522,7 +522,7 @@ testOrdFunctions _ = $(testProperties 'prop_minIndex, 'prop_maxIndex, 'prop_maximumBy, 'prop_minimumBy, 'prop_maxIndexBy, 'prop_minIndexBy, - 'prop_ListLastMaxIndexWins ]) + 'prop_ListLastMaxIndexWins, 'prop_FalseListFirstMaxIndexWins ]) where prop_compare :: P (v a -> v a -> Ordering) = compare `eq` compare prop_maximum :: P (v a -> a) = not . V.null ===> V.maximum `eq` maximum From b41ca991e13f6cd82f3d0505c7d0807468e57449 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sat, 11 Apr 2020 18:01:28 +0300 Subject: [PATCH 12/14] Fix test so they match behavior of maxIndex & CO since #180 --- tests/Tests/Vector/Property.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/Tests/Vector/Property.hs b/tests/Tests/Vector/Property.hs index 448f83de..4ad37b3e 100644 --- a/tests/Tests/Vector/Property.hs +++ b/tests/Tests/Vector/Property.hs @@ -528,14 +528,13 @@ testOrdFunctions _ = $(testProperties prop_maximum :: P (v a -> a) = not . V.null ===> V.maximum `eq` maximum prop_minimum :: P (v a -> a) = not . V.null ===> V.minimum `eq` minimum prop_minIndex :: P (v a -> Int) = not . V.null ===> V.minIndex `eq` minIndex - prop_maxIndex :: P (v a -> Int) = not . V.null ===> V.maxIndex `eq` listMaxIndexFMW + prop_maxIndex :: P (v a -> Int) = not . V.null ===> V.maxIndex `eq` maxIndex prop_maximumBy :: P (v a -> a) = not . V.null ===> V.maximumBy compare `eq` maximum prop_minimumBy :: P (v a -> a) = not . V.null ===> V.minimumBy compare `eq` minimum prop_maxIndexBy :: P (v a -> Int) = - not . V.null ===> V.maxIndexBy compare `eq` listMaxIndexFMW - --- (maxIndex) + not . V.null ===> V.maxIndexBy compare `eq` maxIndex prop_ListLastMaxIndexWins :: P (v a -> Int) = not . V.null ===> ( maxIndex . V.toList) `eq` listMaxIndexLMW prop_FalseListFirstMaxIndexWinsDesc :: P (v a -> Int) = From cf5a53d7e228eaedac3a8308c223414bb07ccd72 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sun, 12 Apr 2020 16:51:01 +0300 Subject: [PATCH 13/14] Fix build on GHC<=7.8 --- tests/Tests/Vector/Property.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tests/Vector/Property.hs b/tests/Tests/Vector/Property.hs index 4ad37b3e..44414632 100644 --- a/tests/Tests/Vector/Property.hs +++ b/tests/Tests/Vector/Property.hs @@ -30,7 +30,7 @@ import Data.Functor.Identity import qualified Data.Traversable as T (Traversable(..)) import Data.Foldable (Foldable(foldMap)) import Data.Orphans () - +import Data.Monoid import qualified Data.Vector.Generic as V import qualified Data.Vector.Fusion.Bundle as S From c1c4a7681f40c121293e91bcf7813aea476ef8f1 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sun, 12 Apr 2020 16:56:36 +0300 Subject: [PATCH 14/14] Use correct pragma --- Data/Vector/Generic.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/Vector/Generic.hs b/Data/Vector/Generic.hs index c404065c..e80332d6 100644 --- a/Data/Vector/Generic.hs +++ b/Data/Vector/Generic.hs @@ -2210,7 +2210,7 @@ mkVecType name = mkDataType name [mkVecConstr name] mkType :: String -> DataType {-# INLINE mkType #-} -{-# DEPRECATE mkType "Use Data.Data.mkNoRepType: #-} +{-# DEPRECATED mkType "Use Data.Data.mkNoRepType" #-} mkType = mkNoRepType gunfold :: (Vector v a, Data a)