Safe Haskell | None |
---|---|
Language | Haskell2010 |
- genericArbitrary :: (Generic a, GA Unsized (Rep a)) => Weights a -> Gen a
- genericArbitraryU :: (Generic a, GA Unsized (Rep a), UniformWeight_ (Rep a)) => Gen a
- genericArbitrarySingle :: (Generic a, GA Unsized (Rep a), Weights_ (Rep a) ~ L c0) => Gen a
- genericArbitraryRec :: forall a. (Generic a, GA Sized (Rep a)) => Weights a -> Gen a
- type family Weights_ (f :: * -> *) :: * where ...
- data a :| b = N a Int b
- data L c = L
- data Weights a = Weights (Weights_ (Rep a)) Int
- newtype W c = 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
- data Sized
- data Unsized
- class GA sized f where
- gaSum' :: GASum sized f => proxy sized -> Weights_ f -> Int -> Gen (f p)
- class GASum sized f where
- class GAProduct sized f where
- class GAProduct' f where
- type family Arity f :: Nat where ...
- newtype Weighted a = Weighted (Maybe (Int -> Gen a, Int))
- liftGen :: Gen a -> Weighted a
Random generators
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 :: (Generic a, GA Unsized (Rep a), UniformWeight_ (Rep a)) => Gen a Source #
Pick every constructor with equal probability.
Equivalent to
.genericArbitrary
uniform
genericArbitraryU :: Gen a
genericArbitrarySingle :: (Generic a, GA Unsized (Rep 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
Decrease size at every recursive call, but don't do anything different at size 0.
genericArbitraryRec (7 % 11 % 13 % ()) :: Gen a
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 #
Deprecated: Can be omitted
A smart constructor to specify a custom distribution.
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 GA sized f where Source #
Generic Arbitrary
TypeError Constraint ((:$$:) ((:<>:) (Text "Unrecognized Rep: ") (ShowType (* -> *) f)) (Text "Possible cause: missing Generic instance")) => GA sized f Source # | |
(GASum sized f, GASum sized g) => GA sized ((:+:) f g) Source # | |
GAProduct sized f => GA sized (M1 C c f) Source # | |
GA sized f => GA sized (M1 D c f) Source # | |
class GAProduct' f where Source #
gaProduct' :: Gen (f p) Source #
GAProduct' U1 Source # | |
Arbitrary c => GAProduct' (K1 i c) Source # | |
(GAProduct' f, GAProduct' g) => GAProduct' ((:*:) f g) Source # | |
GAProduct' f => GAProduct' (M1 i c f) Source # | |