Community
Modules 18

Test.QuickCheck.Modifiers

Modifiers for test data.

These types do things such as restricting the kind of test data that can be generated. They can be pattern-matched on in properties as a stylistic alternative to using explicit quantification.

Note: the contents of this module are re-exported by Test.QuickCheck. You do not need to import it directly.

Examples:

-- Functions cannot be shown (but see "Test.QuickCheck.Function")
prop_TakeDropWhile ('Blind' p) (xs :: ['Test.QuickCheck.Poly.A']) =
  takeWhile p xs ++ dropWhile p xs == xs
prop_TakeDrop ('NonNegative' n) (xs :: ['Test.QuickCheck.Poly.A']) =
  take n xs ++ drop n xs == xs
-- cycle does not work for empty lists
prop_Cycle ('NonNegative' n) ('NonEmpty' (xs :: ['Test.QuickCheck.Poly.A'])) =
  take n (cycle xs) == take n (xs ++ cycle xs)
-- Instead of 'Test.QuickCheck.forAll' 'orderedList'
prop_Sort ('Ordered' (xs :: ['Test.QuickCheck.Poly.OrdA'])) =
  sort xs == xs

Type-level modifiers for changing generator behavior

newtype Blind a

Blind x: as x, but x does not have to be in the Show class.

newtype Fixed a

Fixed x: as x, but will not be shrunk.

data InfiniteList a

InfiniteList xs _: guarantees that xs is an infinite list. When a counterexample is found, only prints the prefix of xs that was used by the program.

Here is a contrived example property:

prop_take_10 :: InfiniteList Char -> Bool
prop_take_10 (InfiniteList xs _) =
  or [ x == \'a\' | x <- take 10 xs ]

In the following counterexample, the list must start with "bbbbbbbbbb" but the remaining (infinite) part can contain anything:


newtype SortedList a

Sorted xs: guarantees that xs is sorted.

newtype Large a

Large x: by default, QuickCheck generates Ints drawn from a small range. Large Int gives you values drawn from the entire range instead.

newtype Small a

Small x: generates values of x drawn from a small range. The opposite of Large.

data Smart a

Smart _ x: tries a different order when shrinking.

Smart :: Int -> a -> Smart a

newtype Shrink2 a

Shrink2 x: allows 2 shrinking steps at the same time when shrinking x

data Shrinking s a

Shrinking _ x: allows for maintaining a state during shrinking.

Instances

157
  • instance Eq a => Eq (Blind a)
  • instance Ord a => Ord (Blind a)
  • instance Num a => Num (Blind a)
  • instance Integral a => Integral (Blind a)
  • instance Real a => Real (Blind a)
  • instance Enum a => Enum (Blind a)
  • instance Typeable a => Typeable (Blind a)
  • instance Functor Blind
  • instance Show (Blind a)
  • instance Arbitrary a => Arbitrary (Blind a)
  • instance Eq a => Eq (Fixed a)
  • instance Ord a => Ord (Fixed a)
  • instance Show a => Show (Fixed a)
  • instance Read a => Read (Fixed a)
  • instance Num a => Num (Fixed a)
  • instance Integral a => Integral (Fixed a)
  • instance Real a => Real (Fixed a)
  • instance Enum a => Enum (Fixed a)
  • instance Typeable a => Typeable (Fixed a)
  • instance Functor Fixed
  • instance Arbitrary a => Arbitrary (Fixed a)
  • instance Eq a => Eq (OrderedList a)
  • instance Ord a => Ord (OrderedList a)
  • instance Show a => Show (OrderedList a)
  • instance Read a => Read (OrderedList a)
  • instance Typeable a => Typeable (OrderedList a)
  • instance Functor OrderedList
  • instance (Ord a, Arbitrary a) => Arbitrary (OrderedList a)
  • instance Eq a => Eq (NonEmptyList a)
  • instance Ord a => Ord (NonEmptyList a)
  • instance Show a => Show (NonEmptyList a)
  • instance Read a => Read (NonEmptyList a)
  • instance Typeable a => Typeable (NonEmptyList a)
  • instance Functor NonEmptyList
  • instance Arbitrary1 NonEmptyList
  • instance Arbitrary a => Arbitrary (NonEmptyList a)
  • instance Show a => Show (InfiniteList a)
  • instance Arbitrary a => Arbitrary (InfiniteList a)
  • instance Arbitrary a => Arbitrary (InfiniteListInternalData a)
  • instance Eq a => Eq (SortedList a)
  • instance Ord a => Ord (SortedList a)
  • instance Show a => Show (SortedList a)
  • instance Read a => Read (SortedList a)
  • instance Typeable a => Typeable (SortedList a)
  • instance Functor SortedList
  • instance (Arbitrary a, Ord a) => Arbitrary (SortedList a)
  • instance Eq a => Eq (Positive a)
  • instance Ord a => Ord (Positive a)
  • instance Show a => Show (Positive a)
  • instance Read a => Read (Positive a)
  • instance Enum a => Enum (Positive a)
  • instance Typeable a => Typeable (Positive a)
  • instance Functor Positive
  • instance (Num a, Ord a, Arbitrary a) => Arbitrary (Positive a)
  • instance Eq a => Eq (Negative a)
  • instance Ord a => Ord (Negative a)
  • instance Show a => Show (Negative a)
  • instance Read a => Read (Negative a)
  • instance Enum a => Enum (Negative a)
  • instance Typeable a => Typeable (Negative a)
  • instance Functor Negative
  • instance (Num a, Ord a, Arbitrary a) => Arbitrary (Negative a)
  • instance Eq a => Eq (NonZero a)
  • instance Ord a => Ord (NonZero a)
  • instance Show a => Show (NonZero a)
  • instance Read a => Read (NonZero a)
  • instance Enum a => Enum (NonZero a)
  • instance Typeable a => Typeable (NonZero a)
  • instance Functor NonZero
  • instance (Num a, Eq a, Arbitrary a) => Arbitrary (NonZero a)
  • instance Eq a => Eq (NonNegative a)
  • instance Ord a => Ord (NonNegative a)
  • instance Show a => Show (NonNegative a)
  • instance Read a => Read (NonNegative a)
  • instance Enum a => Enum (NonNegative a)
  • instance Typeable a => Typeable (NonNegative a)
  • instance Functor NonNegative
  • instance (Num a, Ord a, Arbitrary a) => Arbitrary (NonNegative a)
  • instance Eq a => Eq (NonPositive a)
  • instance Ord a => Ord (NonPositive a)
  • instance Show a => Show (NonPositive a)
  • instance Read a => Read (NonPositive a)
  • instance Enum a => Enum (NonPositive a)
  • instance Typeable a => Typeable (NonPositive a)
  • instance Functor NonPositive
  • instance (Num a, Ord a, Arbitrary a) => Arbitrary (NonPositive a)
  • instance Eq a => Eq (Large a)
  • instance Ord a => Ord (Large a)
  • instance Show a => Show (Large a)
  • instance Read a => Read (Large a)
  • instance Num a => Num (Large a)
  • instance Integral a => Integral (Large a)
  • instance Real a => Real (Large a)
  • instance Enum a => Enum (Large a)
  • instance Ix a => Ix (Large a)
  • instance Typeable a => Typeable (Large a)
  • instance Functor Large
  • instance (Integral a, Bounded a) => Arbitrary (Large a)
  • instance Eq a => Eq (Small a)
  • instance Ord a => Ord (Small a)
  • instance Show a => Show (Small a)
  • instance Read a => Read (Small a)
  • instance Num a => Num (Small a)
  • instance Integral a => Integral (Small a)
  • instance Real a => Real (Small a)
  • instance Enum a => Enum (Small a)
  • instance Ix a => Ix (Small a)
  • instance Typeable a => Typeable (Small a)
  • instance Functor Small
  • instance Integral a => Arbitrary (Small a)
  • instance Eq a => Eq (Shrink2 a)
  • instance Ord a => Ord (Shrink2 a)
  • instance Show a => Show (Shrink2 a)
  • instance Read a => Read (Shrink2 a)
  • instance Num a => Num (Shrink2 a)
  • instance Integral a => Integral (Shrink2 a)
  • instance Real a => Real (Shrink2 a)
  • instance Enum a => Enum (Shrink2 a)
  • instance Typeable a => Typeable (Shrink2 a)
  • instance Functor Shrink2
  • instance Arbitrary a => Arbitrary (Shrink2 a)
  • instance Eq a => Eq (NoShrink a)
  • instance Ord a => Ord (NoShrink a)
  • instance Show a => Show (NoShrink a)
  • instance Read a => Read (NoShrink a)
  • instance Num a => Num (NoShrink a)
  • instance Integral a => Integral (NoShrink a)
  • instance Real a => Real (NoShrink a)
  • instance Enum a => Enum (NoShrink a)
  • instance Ix a => Ix (NoShrink a)
  • instance Typeable a => Typeable (NoShrink a)
  • instance Functor NoShrink
  • instance Arbitrary a => Arbitrary (NoShrink a)
  • instance Functor Smart
  • instance Show a => Show (Smart a)
  • instance Arbitrary a => Arbitrary (Smart a)
  • instance Functor (Shrinking s)
  • instance Show a => Show (Shrinking s a)
  • instance (Arbitrary a, ShrinkState s a) => Arbitrary (Shrinking s a)
  • instance Eq ASCIIString
  • instance Ord ASCIIString
  • instance Show ASCIIString
  • instance Read ASCIIString
  • instance Typeable ASCIIString
  • instance Arbitrary ASCIIString
  • instance Eq UnicodeString
  • instance Ord UnicodeString
  • instance Show UnicodeString
  • instance Read UnicodeString
  • instance Typeable UnicodeString
  • instance Arbitrary UnicodeString
  • instance Eq PrintableString
  • instance Ord PrintableString
  • instance Show PrintableString
  • instance Read PrintableString
  • instance Typeable PrintableString
  • instance Arbitrary PrintableString
Build record and source files

Community contribution. The service has not verified this documentation. The generator reported 30 diagnostics.

Target: Linux on x86-64. Some inferred types and resolved links are not available.

Generator: aihc-haddock-aa6debbd-web-3

Metadata snapshot: f17ab6aeb2a7b6daf9fba7614097e138beeef85fa92c3fb7fdfed9ed0e49728c

Open the dependency plan · Download the documentation model

Import a package

Enter a package name and an exact version from Hackage. The site contains imported versions only.