File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ module Test.QuickCheck.Arbitrary where
22
33import Prelude
44
5- import Data.Array ((:))
65import Data.Char (toCharCode , fromCharCode )
76import Data.Either (Either (..))
87import Data.Maybe (Maybe (..))
@@ -80,12 +79,7 @@ instance coarbOrdering :: Coarbitrary Ordering where
8079 coarbitrary GT = perturbGen 3.0
8180
8281instance arbArray :: (Arbitrary a ) => Arbitrary (Array a ) where
83- arbitrary = do
84- b <- arbitrary
85- if b then return [] else do
86- a <- arbitrary
87- as <- arbitrary
88- return (a : as)
82+ arbitrary = arrayOf arbitrary
8983
9084instance coarbArray :: (Coarbitrary a ) => Coarbitrary (Array a ) where
9185 coarbitrary = foldl (\f x -> f <<< coarbitrary x) id
Original file line number Diff line number Diff line change @@ -127,7 +127,9 @@ arrayOf1 g = sized $ \n ->
127127
128128-- | Create a random generator which generates a vector of random values of a specified size.
129129vectorOf :: forall a . Int -> Gen a -> Gen (Array a )
130- vectorOf k g = sequence $ const g <$> range one k
130+ vectorOf k g
131+ | k <= 0 = return []
132+ | otherwise = sequence $ const g <$> range one k
131133
132134-- | Create a random generator which selects a value from a non-empty collection with
133135-- | uniform probability.
You can’t perform that action at this time.
0 commit comments