Safe Haskell  None 

Language  Haskell2010 
 genericArbitrary :: GArbitrary UnsizedOpts a => Weights a > Gen a
 genericArbitraryU :: (GArbitrary UnsizedOpts a, GUniformWeight a) => Gen a
 genericArbitrarySingle :: (GArbitrary UnsizedOpts a, Weights_ (Rep a) ~ L c0) => Gen a
 genericArbitraryRec :: GArbitrary SizedOpts a => Weights a > Gen a
 genericArbitraryG :: GArbitrary (SetGens g UnsizedOpts) a => GenList g > Weights a > Gen a
 genericArbitraryUG :: (GArbitrary (SetGens g UnsizedOpts) a, GUniformWeight a) => GenList g > Gen a
 genericArbitrarySingleG :: (GArbitrary (SetGens g UnsizedOpts) a, Weights_ (Rep a) ~ L c0) => GenList g > Gen a
 genericArbitraryRecG :: GArbitrary (SetGens g SizedOpts) a => GenList g > Weights a > Gen a
 genericArbitraryWith :: GArbitrary opts a => opts > Weights a > Gen a
 type family Weights_ (f :: * > *) :: * where ...
 data a : b = N a Int b
 data L (c :: Symbol) = L
 data Weights a = Weights (Weights_ (Rep a)) Int
 newtype W (c :: Symbol) = W Int
 weights :: (Weights_ (Rep a), Int, ()) > Weights a
 uniform :: UniformWeight_ (Rep a) => Weights a
 type family First a :: Symbol where ...
 type family First' w where ...
 type family Prec' w where ...
 class WeightBuilder' w where
 class WeightBuilder a where
 type Prec a r
 class UniformWeight a where
 class UniformWeight (Weights_ f) => UniformWeight_ f
 class UniformWeight_ (Rep a) => GUniformWeight a
 data Options (s :: Sizing) (g :: [Type]) = Options {
 _generators :: GenList g
 unsizedOpts :: UnsizedOpts
 sizedOpts :: SizedOpts
 data Sizing
 type UnsizedOpts = (Options Unsized '[] :: Type)
 type SizedOpts = (Options Sized '[] :: Type)
 type family SizingOf opts :: Sizing
 proxySizing :: opts > Proxy (SizingOf opts)
 setSized :: Options s g > Options Sized g
 setUnsized :: Options s g > Options Unsized g
 data GenList (g :: [Type]) where
 type family GeneratorsOf opts :: [Type]
 class HasGenerators opts where
 setGenerators :: GenList g > Options s g0 > Options s g
 type family SetGens (g :: [Type]) opts
 newtype Field (s :: Symbol) a = Field {
 unField :: a
 field :: proxy s > a > Field s a
 class GA opts f where
 class (Generic a, GA opts (Rep a)) => GArbitrary opts a
 gaSum' :: GASum opts f => opts > Weights_ f > Int > Gen (f p)
 class GASum opts f where
 class GAProduct (s :: Sizing) opts f where
 class GAProduct' opts f where
 type family Arity f :: Nat where ...
 class ArbitraryOr (g :: [Type]) (sel :: Maybe Symbol) a where
 type family SelectorName (d :: Meta) :: Maybe Symbol
 newtype Weighted a = Weighted (Maybe (Int > Gen a, Int))
 liftGen :: Gen a > Weighted a
Random generators
:: GArbitrary UnsizedOpts a  
=> Weights a  List of weights for every constructor 
> Gen a 
Pick a constructor with a given distribution, and fill its fields
with recursive calls to arbitrary
.
Example
genericArbitrary (2 % 3 % 5 % ()) :: Gen a
Picks the first constructor with probability 2/10
,
the second with probability 3/10
, the third with probability 5/10
.
genericArbitraryU :: (GArbitrary UnsizedOpts a, GUniformWeight a) => Gen a Source #
Pick every constructor with equal probability.
Equivalent to
.genericArbitrary
uniform
genericArbitraryU :: Gen a
genericArbitrarySingle :: (GArbitrary UnsizedOpts a, Weights_ (Rep a) ~ L c0) => Gen a Source #
arbitrary
for types with one constructor.
Equivalent to genericArbitraryU
, with a stricter type.
genericArbitrarySingle :: Gen a
:: GArbitrary SizedOpts a  
=> Weights a  List of weights for every constructor 
> Gen a 
Decrease size at every recursive call, but don't do anything different at size 0.
genericArbitraryRec (7 % 11 % 13 % ()) :: Gen a
genericArbitraryG :: GArbitrary (SetGens g UnsizedOpts) a => GenList g > Weights a > Gen a Source #
genericArbitrary
with explicit generators.
Example
genericArbitraryG customGens (17 % 19 % ())
where, for example to override generators for String
and Int
fields,
customGens ::GenList
'[String, Int] customGens = (filter (/= '\NUL')<$>
arbitrary):@
(getNonNegative<$>
arbitrary):@
Nil
Note on multiple matches
If the list contains multiple matching types for a field x
of type a
(i.e., either a
or
), the generator for the first
match will be picked.Field
"x" a
genericArbitraryUG :: (GArbitrary (SetGens g UnsizedOpts) a, GUniformWeight a) => GenList g > Gen a Source #
genericArbitraryU
with explicit generators.
See also genericArbitraryG
.
genericArbitrarySingleG :: (GArbitrary (SetGens g UnsizedOpts) a, Weights_ (Rep a) ~ L c0) => GenList g > Gen a Source #
genericArbitrarySingle
with explicit generators.
See also genericArbitraryG
.
:: GArbitrary (SetGens g SizedOpts) a  
=> GenList g  
> Weights a  List of weights for every constructor 
> Gen a 
genericArbitraryRec
with explicit generators.
See also genericArbitraryG
.
genericArbitraryWith :: GArbitrary opts a => opts > Weights a > Gen a Source #
General generic generator with custom options.
Internal
(UniformWeight a, UniformWeight b) => UniformWeight ((:) a b) Source #  
WeightBuilder a => WeightBuilder ((:) a b) Source #  
type Prec ((:) a b) r Source #  
Trees of weights assigned to constructors of type a
,
rescaled to obtain a probability distribution.
Two ways of constructing them.
(x1%
x2%
...%
xn%
()) ::Weights
auniform
::Weights
a
Using (
, there must be exactly as many weights as
there are constructors.%
)
uniform
is equivalent to (1
(automatically fills out the right number of 1s).%
... %
1 %
())
WeightBuilder (Weights_ (Rep a)) => WeightBuilder' (Weights a) Source #  
weights :: (Weights_ (Rep a), Int, ()) > Weights a Source #
A smart constructor to specify a custom distribution.
It can be omitted for the %
operator is overloaded to
insert it.
class WeightBuilder' w where Source #
(%) :: W (First' w) > Prec' w > w infixr 1 Source #
A binary constructor for building up trees of weights.
WeightBuilder (Weights_ (Rep a)) => WeightBuilder' (Weights a) Source #  
WeightBuilder a => WeightBuilder' (a, Int, r) Source #  
class WeightBuilder a where Source #
WeightBuilder () Source #  
WeightBuilder (L c) Source #  
WeightBuilder a => WeightBuilder ((:) a b) Source #  
class UniformWeight a where Source #
uniformWeight :: (a, Int) Source #
UniformWeight () Source #  
UniformWeight (L c) Source #  
(UniformWeight a, UniformWeight b) => UniformWeight ((:) a b) Source #  
class UniformWeight (Weights_ f) => UniformWeight_ f Source #
UniformWeight (Weights_ f) => UniformWeight_ f Source #  
class UniformWeight_ (Rep a) => GUniformWeight a Source #
Derived uniform distribution of constructors for a
.
UniformWeight_ (Rep a) => GUniformWeight a Source #  
data Options (s :: Sizing) (g :: [Type]) Source #
Typelevel options for GArbitrary
.
Options  

proxySizing :: opts > Proxy (SizingOf opts) Source #
type family GeneratorsOf opts :: [Type] Source #
type GeneratorsOf (Options _s g) Source #  
class HasGenerators opts where Source #
generators :: opts > GenList (GeneratorsOf opts) Source #
HasGenerators (Options s g) Source #  
newtype Field (s :: Symbol) a Source #
A marker for a generator which overrides a specific field
named s
.
Available only for base >= 4.9
.
class GAProduct' opts f where Source #
gaProduct' :: opts > Gen (f p) Source #
GAProduct' opts (U1 *) Source #  
(GAProduct' opts f, GAProduct' opts g) => GAProduct' opts ((:*:) * f g) Source #  
(HasGenerators opts, ArbitraryOr (GeneratorsOf opts) (SelectorName d) c) => GAProduct' opts (S1 * d (K1 * i c)) Source #  
class ArbitraryOr (g :: [Type]) (sel :: Maybe Symbol) a where Source #
arbitraryOr :: proxy sel > GenList g > Gen a Source #
Arbitrary a => ArbitraryOr ([] Type) sel a Source #  
ArbitraryOr g sel a => ArbitraryOr ((:) Type b g) sel a Source #  
ArbitraryOr ((:) Type a g) sel a Source #  
ArbitraryOr ((:) * (Field n a) g) (Just Symbol n) a Source #  
type family SelectorName (d :: Meta) :: Maybe Symbol Source #
type SelectorName (MetaSel mn su ss ds) Source #  