Safe Haskell | None |
---|---|
Language | Haskell2010 |
Generic.Random.Internal.Generic
Contents
- 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
Arguments
:: (Generic a, GA Unsized (Rep a)) | |
=> Weights a | List of weights for every constructor |
-> Gen a |
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 #
Shorthand for
.genericArbitrary
uniform
Arguments
:: (Generic a, GA (Sized n) (Rep a)) | |
=> n | |
-> Weights a | List of weights for every constructor |
-> Gen a |
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 #
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 #
Shorthand for
, using nullary
constructors and constructors whose fields are all nullary as base cases.genericArbitrary'
(S
Z
) uniform
Internal
Instances
(UniformWeight a, UniformWeight b) => UniformWeight ((:|) a b) # | |
WeightBuilder a => WeightBuilder ((:|) a b) # | |
type Prec ((:|) a b) r # | |
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 #
A smart constructor to specify a custom distribution.
class WeightBuilder a where #
Minimal complete definition
Methods
(%) :: W (First a) -> Prec a r -> (a, Int, r) infixr 1 #
A binary constructor for building up trees of weights.
Instances
WeightBuilder () # | |
WeightBuilder (L c) # | |
WeightBuilder a => WeightBuilder ((:|) a b) # | |
class UniformWeight a where #
Minimal complete definition
Methods
uniformWeight :: (a, Int) #
Instances
UniformWeight () # | |
UniformWeight (L c) # | |
(UniformWeight a, UniformWeight b) => UniformWeight ((:|) a b) # | |
Generic Arbitrary
Minimal complete definition
Instances
Minimal complete definition
Minimal complete definition
Use the Z
and S
data types to define the depths of values used
by genericArbitrary'
to make generators terminate.
Successor
Constructors
S n |
Instances
(Generic c, ListBaseCases n (Rep c)) => ListBaseCases (S n) (K1 i c) # | |
Instances
Minimal complete definition
class ListBaseCases n f where #
A ListBaseCases n (
constraint basically provides the list of
values of type Rep
a)a
with depth at most n
.
Minimal complete definition
Methods
listBaseCases :: Alternative u => Tagged n (u (f p)) #
Instances
ListBaseCases n U1 # | |
(ListBaseCases n f, ListBaseCases n g) => ListBaseCases n ((:*:) f g) # | |
(ListBaseCases n f, ListBaseCases n g) => ListBaseCases n ((:+:) f g) # | |
ListBaseCases Z (K1 i c) # | |
ListBaseCases n f => ListBaseCases n (M1 i c f) # | |
(Generic c, ListBaseCases n (Rep c)) => ListBaseCases (S n) (K1 i c) # | |
type BaseCases' n a = (Generic a, ListBaseCases n (Rep a)) #
For convenience.