vector is a QuickCheck generator combinator that produces a list of a specified length, choosing each element through the element type’s Arbitrary instance. section 9.4.1
Use vector when the test requires:
- A fixed-length list of randomly generated values. section 9.4.1
- Automatic selection of the element generator from the requested type. section 9.4.1
- A contrast with vectorOf, which receives its element generator explicitly. section 9.4.1
Fixed-length test data
A generator such as vector n can create a list of n values when the element type has an Arbitrary instance. This makes it suitable for constructing fixed-size inputs for QuickCheck properties, while vectorOf is the alternative when the element generator must be supplied directly. section 9.4.1
ghci> import Data.Vector as V ghci> :t V.empty V.empty :: Vector a ghci> :t V.cons V.cons :: a -> Vector a -> Vector a ghci> V.cons 1 V.empty :: V.Vector Int [1] ghci> V.fromList [1..10] :: V.Vector Int [1,2,3,4,5,6,7,8,9,10]
Do not confuse QuickCheck’s vector generator with Data.Vector, an array-like data structure used for fast indexing and reading. section 13.1.3 section 9.4.1
