Safe Haskell | None |
---|---|
Language | Haskell2010 |
- genericArbitrary :: forall a. (Generic a, GA Unsized (Rep a)) => Weights a -> Gen a
- genericArbitraryU :: forall a. (Generic a, GA Unsized (Rep a), UniformWeight (Weights_ (Rep a))) => Gen a
- genericArbitrary' :: forall n a. (Generic a, GA (Sized n) (Rep a)) => n -> Weights a -> Gen a
- genericArbitraryU0 :: forall n a. (Generic a, GA (Sized Z) (Rep a), UniformWeight (Weights_ (Rep a))) => Gen a
- genericArbitraryU1 :: forall n a. (Generic a, GA (Sized (S Z)) (Rep a), UniformWeight (Weights_ (Rep 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 (Weights_ (Rep a)) => Weights a
- type family First a :: Symbol where ...
- class WeightBuilder a where
- type Prec a r
- class UniformWeight a where
- newtype Gen' sized a = Gen' {}
- data Sized n
- data Unsized
- sized' :: (Int -> Gen' sized a) -> Gen' sized a
- class GA sized f where
- gArbitrarySingle :: forall sized f p c0. (GA sized f, Weights_ f ~ L c0) => Gen' sized (f p)
- gaSum' :: GASum sized f => Weights_ f -> Int -> Gen' sized (f p)
- class GASum sized f where
- class GAProduct f where
- type family Arity f :: Nat where ...
- newtype Tagged a b = Tagged {
- unTagged :: b
- data Z = Z
- data S n = S n
- newtype Weighted a = Weighted (Maybe (Int -> Gen a, Int))
- class BaseCases n f where
- class ListBaseCases n f where
- type BaseCases' n a = (Generic a, ListBaseCases n (Rep a))
Random generators
Pick a constructor with a given distribution, and fill its fields recursively.
genericArbitraryU :: forall a. (Generic a, GA Unsized (Rep a), UniformWeight (Weights_ (Rep a))) => Gen a Source #
Shorthand for
.genericArbitrary
uniform
Like genericArbitrary'
, with decreasing size to ensure termination for
recursive types, looking for base cases once the size reaches 0.
genericArbitraryU0 :: forall n a. (Generic a, GA (Sized Z) (Rep a), UniformWeight (Weights_ (Rep a))) => Gen a Source #
Shorthand for
, using nullary
constructors as the base cases.genericArbitrary'
Z
uniform
genericArbitraryU1 :: forall n a. (Generic a, GA (Sized (S Z)) (Rep a), UniformWeight (Weights_ (Rep a))) => Gen a Source #
Shorthand for
, using nullary
constructors and constructors whose fields are all nullary as base cases.genericArbitrary'
(S
Z
) uniform
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.
weights
(x1%
x2%
...%
xn%
()) ::Weights
auniform
::Weights
a
Using weights
, there must be exactly as many weights as
there are constructors.
uniform
is equivalent to
(automatically fills out the right number of 1s).weights
(1 %
... %
1 %
())
weights :: (Weights_ (Rep a), Int, ()) -> Weights a Source #
A smart constructor to specify a custom distribution.
class WeightBuilder a where Source #
(%) :: W (First a) -> Prec a r -> (a, Int, r) infixr 1 Source #
A binary constructor for building up trees of weights.
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 GA sized f where Source #
Generic Arbitrary
(GASum Unsized f, GASum Unsized g) => GA Unsized ((:+:) f g) Source # | |
GA sized f => GA sized (M1 D c f) Source # | |
GAProduct f => GA Unsized (M1 C c f) Source # | |
(GASum (Sized n) f, GASum (Sized n) g, BaseCases n f, BaseCases n g) => GA (Sized n) ((:+:) f g) Source # | |
(GAProduct f, KnownNat (Arity f)) => GA (Sized n) (M1 C c f) Source # | |
gArbitrarySingle :: forall sized f p c0. (GA sized f, Weights_ f ~ L c0) => Gen' sized (f p) Source #
Use the Z
and S
data types to define the depths of values used
by genericArbitrary'
to make generators terminate.
class ListBaseCases n f where Source #
A ListBaseCases n (
constraint basically provides the list of
values of type Rep
a)a
with depth at most n
.
listBaseCases :: Alternative u => Tagged n (u (f p)) Source #
ListBaseCases n U1 Source # | |
(ListBaseCases n f, ListBaseCases n g) => ListBaseCases n ((:*:) f g) Source # | |
(ListBaseCases n f, ListBaseCases n g) => ListBaseCases n ((:+:) f g) Source # | |
ListBaseCases Z (K1 i c) Source # | |
ListBaseCases n f => ListBaseCases n (M1 i c f) Source # | |
(Generic c, ListBaseCases n (Rep c)) => ListBaseCases (S n) (K1 i c) Source # | |
type BaseCases' n a = (Generic a, ListBaseCases n (Rep a)) Source #
For convenience.