Documentation
runGen
takes a Gen a
, a max depth of the expression, the weights, and
the standard random generator.
randomFromType :: Type a -> Gen aSource
freq :: [(Int, Gen a)] -> Gen aSource
Takes a list of pairs (weight, Gen), and choose the Gen based on the weights. To get the frequency of choosing a Gen, sum up all the weights, and choose c between 1 and the total. Now recurse down the list, choosing an item only when c <= weight. If not, subtract the current weight from c.