HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

ModuleQuickCheck-2.15.0.1Haskell2010

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 :: [A]) =
  takeWhile p xs ++ dropWhile p xs == xs
prop_TakeDrop (NonNegative n) (xs :: [A]) =
  take n xs ++ drop n xs == xs
-- cycle does not work for empty lists
prop_Cycle (NonNegative n) (NonEmpty (xs :: [A])) =
  take n (cycle xs) == take n (xs ++ cycle xs)
-- Instead of forAll orderedList
prop_Sort (Ordered (xs :: [OrdA])) =
  sort xs == xs
  • 19 types
  • 1 class

Type-level modifiers for changing generator behavior

20 declarations
newtypenewtype Blind a
#

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

Constructors

Instances9Functor, Enum, Eq, Integral, Num, Ord, …
  • Functor BlindDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Eq a => Eq (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Num a => Num (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ord a => Ord (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Arbitrary a => Arbitrary (Blind a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
newtypenewtype Fixed a
#

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

Constructors

Instances10Functor, Enum, Eq, Integral, Num, Ord, …
  • Functor FixedDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Eq a => Eq (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Num a => Num (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ord a => Ord (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Arbitrary a => Arbitrary (Fixed a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
newtypenewtype OrderedList a
#

Ordered xs: guarantees that xs is ordered.

Constructors

Instances6Functor, Eq, Ord, Read, Show, Arbitrary
newtypenewtype NonEmptyList a
#

NonEmpty xs: guarantees that xs is non-empty.

Constructors

Instances6Functor, Eq, Ord, Read, Show, Arbitrary
datadata 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:

Example1 expression
quickCheck prop_take_10*** Failed! Falsified (after 1 test and 14 shrinks):"bbbbbbbbbb" ++ ...

Constructors

Instances2Show, Arbitrary
newtypenewtype SortedList a
#

Sorted xs: guarantees that xs is sorted.

Constructors

Instances6Functor, Eq, Ord, Read, Show, Arbitrary
newtypenewtype Positive a
#

Positive x: guarantees that x > 0.

Constructors

Instances7Functor, Enum, Eq, Ord, Read, Show, …
  • Functor PositiveDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Eq a => Eq (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ord a => Ord (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • (Num a, Ord a, Arbitrary a) => Arbitrary (Positive a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
newtypenewtype Negative a
#

Negative x: guarantees that x < 0.

Constructors

Instances7Functor, Enum, Eq, Ord, Read, Show, …
  • Functor NegativeDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Eq a => Eq (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ord a => Ord (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • (Num a, Ord a, Arbitrary a) => Arbitrary (Negative a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
newtypenewtype NonZero a
#

NonZero x: guarantees that x /= 0.

Constructors

Instances7Functor, Enum, Eq, Ord, Read, Show, …
  • Functor NonZeroDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Eq a => Eq (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ord a => Ord (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • (Num a, Eq a, Arbitrary a) => Arbitrary (NonZero a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
newtypenewtype NonNegative a
#

NonNegative x: guarantees that x >= 0.

Constructors

Instances7Functor, Enum, Eq, Ord, Read, Show, …
newtypenewtype NonPositive a
#

NonPositive x: guarantees that x <= 0.

Constructors

Instances7Functor, Enum, Eq, Ord, Read, Show, …
newtypenewtype 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.

Constructors

Instances11Functor, Enum, Eq, Integral, Num, Ord, …
  • Functor LargeDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Eq a => Eq (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Num a => Num (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ord a => Ord (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ix a => Ix (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • (Integral a, Bounded a) => Arbitrary (Large a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
newtypenewtype Small a
#

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

Constructors

Instances11Functor, Enum, Eq, Integral, Num, Ord, …
  • Functor SmallDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Eq a => Eq (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Num a => Num (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ord a => Ord (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ix a => Ix (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Arbitrary (Small a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
datadata Smart a
#

Smart _ x: tries a different order when shrinking.

Constructors

Instances3Functor, Show, Arbitrary
  • Functor SmartDefined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Smart a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Arbitrary a => Arbitrary (Smart a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
newtypenewtype Shrink2 a
#

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

Constructors

Instances10Functor, Enum, Eq, Integral, Num, Ord, …
  • Functor Shrink2Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Enum a => Enum (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Eq a => Eq (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Integral a => Integral (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Num a => Num (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Ord a => Ord (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Read a => Read (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Real a => Real (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Show a => Show (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
  • Arbitrary a => Arbitrary (Shrink2 a)Defined in QuickCheck-2.15.0.1 · Test.QuickCheck.Modifiers
newtypenewtype ASCIIString
#

ASCIIString: generates an ASCII string.

Instances5Eq, Ord, Read, Show, Arbitrary
newtypenewtype UnicodeString
#

UnicodeString: generates a unicode String. The string will not contain surrogate pairs.

Instances5Eq, Ord, Read, Show, Arbitrary
newtypenewtype PrintableString
#

PrintableString: generates a printable unicode String. The string will not contain surrogate pairs.

Instances5Eq, Ord, Read, Show, Arbitrary