Skip to content

Commit

Permalink
Merge pull request #101 from haskellari/prim-vector
Browse files Browse the repository at this point in the history
Add instances for primitive vectors
  • Loading branch information
phadej authored Nov 4, 2024
2 parents 51d772b + 6c42811 commit 92dfa8a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.3.32

* Add instances for primitive vectors

0.3.31

* Support GHC-8.6.5...GHC-9.10.1
Expand Down
3 changes: 1 addition & 2 deletions quickcheck-instances.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cabal-version: 2.2
name: quickcheck-instances
version: 0.3.31
x-revision: 2
version: 0.3.32
synopsis: Common quickcheck instances
description:
QuickCheck instances.
Expand Down
22 changes: 18 additions & 4 deletions src/Test/QuickCheck/Instances/Vector.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import Test.QuickCheck.Instances.CustomPrelude
import Test.QuickCheck
import Test.QuickCheck.Function ((:->))

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Storable as SVector
import qualified Data.Vector.Unboxed as UVector
import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Primitive as PVector
import qualified Data.Vector.Storable as SVector
import qualified Data.Vector.Unboxed as UVector

-------------------------------------------------------------------------------
-- vector
Expand Down Expand Up @@ -51,6 +52,19 @@ instance (UVector.Unbox a, CoArbitrary a) => CoArbitrary (UVector.Vector a) wher
instance (UVector.Unbox a, Function a) => Function (UVector.Vector a) where
function = functionVector

-- | @since 0.3.32
instance (PVector.Prim a, Arbitrary a) => Arbitrary (PVector.Vector a) where
arbitrary = arbitraryVector
shrink = shrinkVector

-- | @since 0.3.32
instance (PVector.Prim a, CoArbitrary a) => CoArbitrary (PVector.Vector a) where
coarbitrary = coarbitraryVector

-- | @since 0.3.32
instance (PVector.Prim a, Function a) => Function (PVector.Vector a) where
function = functionVector

arbitraryVector :: (GVector.Vector v a, Arbitrary a) => Gen (v a)
arbitraryVector = GVector.fromList `fmap` arbitrary

Expand Down

0 comments on commit 92dfa8a

Please sign in to comment.