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




data Gen a Source

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


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

oneOf :: [Gen 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.

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

elements :: [a] -> Gen aSource