generic-random-1.5.0.1: Generic random generators for QuickCheck

Safe Haskell | None
Language | Haskell2010

Generic.Random.DerivingVia

Synopsis

- newtype GenericArbitrary (weights :: k) a = GenericArbitrary {
  - unGenericArbitrary :: a
  }
- newtype GenericArbitraryU a = GenericArbitraryU {
  - unGenericArbitraryU :: a
  }
- newtype GenericArbitrarySingle a = GenericArbitrarySingle {
  - unGenericArbitrarySingle :: a
  }
- newtype GenericArbitraryRec (weights :: k) a = GenericArbitraryRec {
  - unGenericArbitraryRec :: a
  }
- newtype GenericArbitraryG (genList :: k) (weights :: k1) a = GenericArbitraryG {
  - unGenericArbitraryG :: a
  }
- newtype GenericArbitraryUG (genList :: k) a = GenericArbitraryUG {
  - unGenericArbitraryUG :: a
  }
- newtype GenericArbitrarySingleG (genList :: k) a = GenericArbitrarySingleG {
  - unGenericArbitrarySingleG :: a
  }
- newtype GenericArbitraryRecG (genList :: k) (weights :: k1) a = GenericArbitraryRecG {
  - unGenericArbitraryRecG :: a
  }
- newtype GenericArbitraryWith (opts :: k) (weights :: k1) a = GenericArbitraryWith {
  - unGenericArbitraryWith :: a
  }
- newtype AndShrinking (f :: k) a = AndShrinking a
- class TypeLevelGenList (a :: k) where
  - type TypeLevelGenList' (a :: k)
  - toGenList :: Proxy a -> TypeLevelGenList' a
- class TypeLevelOpts (a :: k) where
  - type TypeLevelOpts' (a :: k)
  - toOpts :: Proxy a -> TypeLevelOpts' a

# Documentation

newtype GenericArbitrary (weights :: k) a Source #

Pick a constructor with a given distribution, and fill its fields with recursive calls to `arbitrary`.

### Example

    data X = ...
      deriving Arbitrary via (GenericArbitrary '[2, 3, 5] X)

Picks the first constructor with probability `2/10`, the second with probability `3/10`, the third with probability `5/10`.

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitrary`.

Since: 1.5.0.0

Constructors

GenericArbitrary |

Fields

- unGenericArbitrary :: a

#### Instances

Instances details

(GArbitrary UnsizedOpts a, TypeLevelWeights' weights a) => Arbitrary (GenericArbitrary weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitrary weights a) Source # shrink :: GenericArbitrary weights a -> [GenericArbitrary weights a] Source #
Show a => Show (GenericArbitrary weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitrary weights a -> ShowS Source # show :: GenericArbitrary weights a -> String Source # showList :: [GenericArbitrary weights a] -> ShowS Source #
Eq a => Eq (GenericArbitrary weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitrary weights a -> GenericArbitrary weights a -> Bool Source # (/=) :: GenericArbitrary weights a -> GenericArbitrary weights a -> Bool Source #

newtype GenericArbitraryU a Source #

Pick every constructor with equal probability.

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitraryU`.

Since: 1.5.0.0

Constructors

GenericArbitraryU |

Fields

- unGenericArbitraryU :: a

#### Instances

Instances details

(GArbitrary UnsizedOpts a, GUniformWeight a) => Arbitrary (GenericArbitraryU a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitraryU a) Source # shrink :: GenericArbitraryU a -> [GenericArbitraryU a] Source #
Show a => Show (GenericArbitraryU a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitraryU a -> ShowS Source # show :: GenericArbitraryU a -> String Source # showList :: [GenericArbitraryU a] -> ShowS Source #
Eq a => Eq (GenericArbitraryU a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitraryU a -> GenericArbitraryU a -> Bool Source # (/=) :: GenericArbitraryU a -> GenericArbitraryU a -> Bool Source #

newtype GenericArbitrarySingle a Source #

`arbitrary` for types with one constructor. Equivalent to `GenericArbitraryU`, with a stricter type.

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitrarySingle`.

Since: 1.5.0.0

Constructors

GenericArbitrarySingle |

Fields

- unGenericArbitrarySingle :: a

#### Instances

Instances details

(GArbitrary UnsizedOpts a, Weights_ (Rep a) ~ L c0) => Arbitrary (GenericArbitrarySingle a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitrarySingle a) Source # shrink :: GenericArbitrarySingle a -> [GenericArbitrarySingle a] Source #
Show a => Show (GenericArbitrarySingle a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitrarySingle a -> ShowS Source # show :: GenericArbitrarySingle a -> String Source # showList :: [GenericArbitrarySingle a] -> ShowS Source #
Eq a => Eq (GenericArbitrarySingle a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitrarySingle a -> GenericArbitrarySingle a -> Bool Source # (/=) :: GenericArbitrarySingle a -> GenericArbitrarySingle a -> Bool Source #

newtype GenericArbitraryRec (weights :: k) a Source #

Decrease size at every recursive call, but don't do anything different at size 0.

    data X = ...
      deriving Arbitrary via (GenericArbitraryRec '[2, 3, 5] X)

N.B.: This replaces the generator for fields of type `[t]` with ``listOf'` arbitrary` instead of ``listOf` arbitrary` (i.e., `arbitrary` for lists).

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitraryRec`.

Since: 1.5.0.0

Constructors

GenericArbitraryRec |

Fields

- unGenericArbitraryRec :: a

#### Instances

Instances details

(GArbitrary SizedOptsDef a, TypeLevelWeights' weights a) => Arbitrary (GenericArbitraryRec weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitraryRec weights a) Source # shrink :: GenericArbitraryRec weights a -> [GenericArbitraryRec weights a] Source #
Show a => Show (GenericArbitraryRec weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitraryRec weights a -> ShowS Source # show :: GenericArbitraryRec weights a -> String Source # showList :: [GenericArbitraryRec weights a] -> ShowS Source #
Eq a => Eq (GenericArbitraryRec weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitraryRec weights a -> GenericArbitraryRec weights a -> Bool Source # (/=) :: GenericArbitraryRec weights a -> GenericArbitraryRec weights a -> Bool Source #

newtype GenericArbitraryG (genList :: k) (weights :: k1) a Source #

`GenericArbitrary` with explicit generators.

### Example

    data X = ...
      deriving Arbitrary via (GenericArbitraryG CustomGens '[2, 3, 5] X)

where, for example, custom generators to override `String` and `Int` fields might look as follows:

    type CustomGens = CustomString :+ CustomInt

### Note on multiple matches

Multiple generators may match a given field: the first will be chosen.

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitraryG`.

Since: 1.5.0.0

Constructors

GenericArbitraryG |

Fields

- unGenericArbitraryG :: a

#### Instances

Instances details

(GArbitrary (SetGens genList UnsizedOpts) a, GUniformWeight a, TypeLevelWeights' weights a, TypeLevelGenList genList', genList ~ TypeLevelGenList' genList') => Arbitrary (GenericArbitraryG genList' weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitraryG genList' weights a) Source # shrink :: GenericArbitraryG genList' weights a -> [GenericArbitraryG genList' weights a] Source #
Show a => Show (GenericArbitraryG genList weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitraryG genList weights a -> ShowS Source # show :: GenericArbitraryG genList weights a -> String Source # showList :: [GenericArbitraryG genList weights a] -> ShowS Source #
Eq a => Eq (GenericArbitraryG genList weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitraryG genList weights a -> GenericArbitraryG genList weights a -> Bool Source # (/=) :: GenericArbitraryG genList weights a -> GenericArbitraryG genList weights a -> Bool Source #

newtype GenericArbitraryUG (genList :: k) a Source #

`GenericArbitraryU` with explicit generators. See also `GenericArbitraryG`.

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitraryUG`.

Since: 1.5.0.0

Constructors

GenericArbitraryUG |

Fields

- unGenericArbitraryUG :: a

#### Instances

Instances details

(GArbitrary (SetGens genList UnsizedOpts) a, GUniformWeight a, TypeLevelGenList genList', genList ~ TypeLevelGenList' genList') => Arbitrary (GenericArbitraryUG genList' a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitraryUG genList' a) Source # shrink :: GenericArbitraryUG genList' a -> [GenericArbitraryUG genList' a] Source #
Show a => Show (GenericArbitraryUG genList a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitraryUG genList a -> ShowS Source # show :: GenericArbitraryUG genList a -> String Source # showList :: [GenericArbitraryUG genList a] -> ShowS Source #
Eq a => Eq (GenericArbitraryUG genList a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitraryUG genList a -> GenericArbitraryUG genList a -> Bool Source # (/=) :: GenericArbitraryUG genList a -> GenericArbitraryUG genList a -> Bool Source #

newtype GenericArbitrarySingleG (genList :: k) a Source #

`genericArbitrarySingle` with explicit generators. See also `GenericArbitraryG`.

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitrarySingleG`.

Since: 1.5.0.0

Constructors

GenericArbitrarySingleG |

Fields

- unGenericArbitrarySingleG :: a

#### Instances

Instances details

(GArbitrary (SetGens genList UnsizedOpts) a, Weights_ (Rep a) ~ L c0, TypeLevelGenList genList', genList ~ TypeLevelGenList' genList') => Arbitrary (GenericArbitrarySingleG genList' a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitrarySingleG genList' a) Source # shrink :: GenericArbitrarySingleG genList' a -> [GenericArbitrarySingleG genList' a] Source #
Show a => Show (GenericArbitrarySingleG genList a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitrarySingleG genList a -> ShowS Source # show :: GenericArbitrarySingleG genList a -> String Source # showList :: [GenericArbitrarySingleG genList a] -> ShowS Source #
Eq a => Eq (GenericArbitrarySingleG genList a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitrarySingleG genList a -> GenericArbitrarySingleG genList a -> Bool Source # (/=) :: GenericArbitrarySingleG genList a -> GenericArbitrarySingleG genList a -> Bool Source #

newtype GenericArbitraryRecG (genList :: k) (weights :: k1) a Source #

`genericArbitraryRec` with explicit generators. See also `genericArbitraryG`.

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitraryRecG`.

Since: 1.5.0.0

Constructors

GenericArbitraryRecG |

Fields

- unGenericArbitraryRecG :: a

#### Instances

Instances details

(GArbitrary (SetGens genList SizedOpts) a, TypeLevelWeights' weights a, TypeLevelGenList genList', genList ~ TypeLevelGenList' genList') => Arbitrary (GenericArbitraryRecG genList' weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitraryRecG genList' weights a) Source # shrink :: GenericArbitraryRecG genList' weights a -> [GenericArbitraryRecG genList' weights a] Source #
Show a => Show (GenericArbitraryRecG genList weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitraryRecG genList weights a -> ShowS Source # show :: GenericArbitraryRecG genList weights a -> String Source # showList :: [GenericArbitraryRecG genList weights a] -> ShowS Source #
Eq a => Eq (GenericArbitraryRecG genList weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitraryRecG genList weights a -> GenericArbitraryRecG genList weights a -> Bool Source # (/=) :: GenericArbitraryRecG genList weights a -> GenericArbitraryRecG genList weights a -> Bool Source #

newtype GenericArbitraryWith (opts :: k) (weights :: k1) a Source #

General generic generator with custom options.

This newtype does no shrinking. To add generic shrinking, use `AndShrinking`.

Uses `genericArbitraryWith`.

Since: 1.5.0.0

Constructors

GenericArbitraryWith |

Fields

- unGenericArbitraryWith :: a

#### Instances

Instances details

(GArbitrary opts a, TypeLevelWeights' weights a, TypeLevelOpts opts', opts ~ TypeLevelOpts' opts') => Arbitrary (GenericArbitraryWith opts' weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (GenericArbitraryWith opts' weights a) Source # shrink :: GenericArbitraryWith opts' weights a -> [GenericArbitraryWith opts' weights a] Source #
Show a => Show (GenericArbitraryWith opts weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> GenericArbitraryWith opts weights a -> ShowS Source # show :: GenericArbitraryWith opts weights a -> String Source # showList :: [GenericArbitraryWith opts weights a] -> ShowS Source #
Eq a => Eq (GenericArbitraryWith opts weights a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: GenericArbitraryWith opts weights a -> GenericArbitraryWith opts weights a -> Bool Source # (/=) :: GenericArbitraryWith opts weights a -> GenericArbitraryWith opts weights a -> Bool Source #

newtype AndShrinking (f :: k) a Source #

Add generic shrinking to a newtype wrapper for `Arbitrary`, using `genericShrink`.

    data X = ...
      deriving Arbitrary via (GenericArbitrary '[1,2,3] `AndShrinking' X)

Equivalent to:

    instance Arbitrary X where
      arbitrary = genericArbitrary (1 % 2 % 3 % ())
      shrink = genericShrink

Since: 1.5.0.0

Constructors

AndShrinking a |

#### Instances

Instances details

(Arbitrary (f a), Coercible (f a) a, Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) => Arbitrary (AndShrinking f a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods arbitrary :: Gen (AndShrinking f a) Source # shrink :: AndShrinking f a -> [AndShrinking f a] Source #
Show a => Show (AndShrinking f a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods showsPrec :: Int -> AndShrinking f a -> ShowS Source # show :: AndShrinking f a -> String Source # showList :: [AndShrinking f a] -> ShowS Source #
Eq a => Eq (AndShrinking f a) Source # |
Instance details Defined in Generic.Random.DerivingVia Methods (==) :: AndShrinking f a -> AndShrinking f a -> Bool Source # (/=) :: AndShrinking f a -> AndShrinking f a -> Bool Source #

class TypeLevelGenList (a :: k) where Source #

Since: 1.5.0.0

Associated Types

type TypeLevelGenList' (a :: k) Source #

Methods

toGenList :: Proxy a -> TypeLevelGenList' a Source #

#### Instances

Instances details

Arbitrary a => TypeLevelGenList (Gen a :: Type) Source # |

Instance details

Defined in Generic.Random.DerivingVia

Associated Types

type TypeLevelGenList' (Gen a :: Type) |
Instance details Defined in Generic.Random.DerivingVia type TypeLevelGenList' (Gen a :: Type) = Gen a

Methods

toGenList :: Proxy (Gen a) -> TypeLevelGenList' (Gen a) Source #

(TypeLevelGenList a, TypeLevelGenList b) => TypeLevelGenList (a :+ b :: Type) Source # |

Instance details

Defined in Generic.Random.DerivingVia

Associated Types

type TypeLevelGenList' (a :+ b :: Type) |
Instance details Defined in Generic.Random.DerivingVia type TypeLevelGenList' (a :+ b :: Type) = TypeLevelGenList' a :+ TypeLevelGenList' b

Methods

toGenList :: Proxy (a :+ b) -> TypeLevelGenList' (a :+ b) Source #

class TypeLevelOpts (a :: k) where Source #

Since: 1.5.0.0

Associated Types

type TypeLevelOpts' (a :: k) Source #

Methods

toOpts :: Proxy a -> TypeLevelOpts' a Source #