copilot-core-2.1.2: An intermediate representation for Copilot.

Safe HaskellSafe
LanguageHaskell2010

Copilot.Core.Random.Gen

Synopsis

Documentation

data Gen a Source

runGen takes a Gen a, a max depth of the expression, the weights, and the standard random generator.

Instances

runGen :: Gen a -> Depth -> Weights -> StdGen -> a Source

oneOf :: [Gen a] -> Gen a Source

freq :: [(Int, Gen a)] -> Gen a Source

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.

choose :: Random a => (a, a) -> Gen a Source

elements :: [a] -> Gen a Source