# Test.QuickCheck.Arbitrary

- Package
- purescript-quickcheck
- Repository
- purescript/purescript-quickcheck

### #Arbitrary Source

`class Arbitrary t where`

The `Arbitrary`

class represents those types whose values can be
*randomly-generated*.

`arbitrary`

uses the `Gen`

monad to express a random generator for
the type `t`

. Combinators in the `Test.QuickCheck.Gen`

module can be used to construct random generators.

#### Members

#### Instances

`Arbitrary Boolean`

`Arbitrary Number`

`Arbitrary Int`

`Arbitrary String`

`Arbitrary NonEmptyString`

`Arbitrary Char`

`Arbitrary Unit`

`Arbitrary Ordering`

`(Arbitrary a) => Arbitrary (Array a)`

`(Arbitrary a) => Arbitrary (NonEmptyArray a)`

`(Coarbitrary a, Arbitrary b) => Arbitrary (a -> b)`

`(Arbitrary a, Arbitrary b) => Arbitrary (Tuple a b)`

`(Arbitrary a) => Arbitrary (Maybe a)`

`(Arbitrary a, Arbitrary b) => Arbitrary (Either a b)`

`(Arbitrary a) => Arbitrary (List a)`

`(Arbitrary a) => Arbitrary (Identity a)`

`(Arbitrary a) => Arbitrary (Lazy a)`

`(Arbitrary (f a), Arbitrary a) => Arbitrary (NonEmpty f a)`

`(Arbitrary a) => Arbitrary (NonEmptyList a)`

`Arbitrary NoArguments`

`(Arbitrary l, ArbitraryGenericSum r) => Arbitrary (Sum l r)`

`(Arbitrary l, Arbitrary r) => Arbitrary (Product l r)`

`(Arbitrary a) => Arbitrary (Constructor s a)`

`(Arbitrary a) => Arbitrary (Argument a)`

`(RowToList row list, ArbitraryRowList list row) => Arbitrary (Record row)`

### #Coarbitrary Source

`class Coarbitrary t where`

The `Coarbitrary`

class represents types which appear on the left of
an `Arbitrary`

function arrow.

To construct an `Arbitrary`

instance for the type `a -> b`

, we need to
use the input of type `a`

to *perturb* a random generator for `b`

. This
is the role of the `coarbitrary`

function.

`Coarbitrary`

instances can be written using the `perturbGen`

function.

#### Members

`coarbitrary :: forall r. t -> Gen r -> Gen r`

#### Instances

`Coarbitrary Boolean`

`Coarbitrary Number`

`Coarbitrary Int`

`Coarbitrary String`

`Coarbitrary NonEmptyString`

`Coarbitrary Char`

`Coarbitrary Unit`

`Coarbitrary Ordering`

`(Coarbitrary a) => Coarbitrary (Array a)`

`(Coarbitrary a) => Coarbitrary (NonEmptyArray a)`

`(Arbitrary a, Coarbitrary b) => Coarbitrary (a -> b)`

`(Coarbitrary a, Coarbitrary b) => Coarbitrary (Tuple a b)`

`(Coarbitrary a) => Coarbitrary (Maybe a)`

`(Coarbitrary a, Coarbitrary b) => Coarbitrary (Either a b)`

`(Coarbitrary a) => Coarbitrary (List a)`

`(Coarbitrary a) => Coarbitrary (Identity a)`

`(Coarbitrary a) => Coarbitrary (Lazy a)`

`(Coarbitrary (f a), Coarbitrary a) => Coarbitrary (NonEmpty f a)`

`(Coarbitrary a) => Coarbitrary (NonEmptyList a)`

`Coarbitrary NoArguments`

`(Coarbitrary l, Coarbitrary r) => Coarbitrary (Sum l r)`

`(Coarbitrary l, Coarbitrary r) => Coarbitrary (Product l r)`

`(Coarbitrary a) => Coarbitrary (Constructor s a)`

`(Coarbitrary a) => Coarbitrary (Argument a)`

### #genericArbitrary Source

`genericArbitrary :: forall a rep. Generic a rep => Arbitrary rep => Gen a`

A `Generic`

implementation of the `arbitrary`

member from the `Arbitrary`

type class.

### #genericCoarbitrary Source

`genericCoarbitrary :: forall a rep. Generic a rep => Coarbitrary rep => a -> Gen a -> Gen a`

A `Generic`

implementation of the `coarbitrary`

member from the `Coarbitrary`

type class.

### #ArbitraryGenericSum Source

`class ArbitraryGenericSum t where`

To be able to evenly distribute over chains of Sum types we build up a collection of generators and choose between. Each right component of a Sum is either a Constructor or another Sum.

#### Members

`arbitraryGenericSum :: Array (Gen t)`

#### Instances

`(Arbitrary l, ArbitraryGenericSum r) => ArbitraryGenericSum (Sum l r)`

`(Arbitrary a) => ArbitraryGenericSum (Constructor s a)`

### #ArbitraryRowList Source

`class ArbitraryRowList list row | list -> row where`

A helper typeclass to implement `Arbitrary`

for records.

#### Members

`arbitraryRecord :: RLProxy list -> Gen (Record row)`

#### Instances

`ArbitraryRowList Nil ()`

`(Arbitrary a, ArbitraryRowList listRest rowRest, Lacks key rowRest, Cons key a rowRest rowFull, RowToList rowFull (Cons key a listRest), IsSymbol key) => ArbitraryRowList (Cons key a listRest) rowFull`