copilot-core-3.0: 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
Monad Gen Source # 
Instance details

Defined in Copilot.Core.Random.Gen

Methods

(>>=) :: Gen a -> (a -> Gen b) -> Gen b #

(>>) :: Gen a -> Gen b -> Gen b #

return :: a -> Gen a #

fail :: String -> Gen a #

Functor Gen Source # 
Instance details

Defined in Copilot.Core.Random.Gen

Methods

fmap :: (a -> b) -> Gen a -> Gen b #

(<$) :: a -> Gen b -> Gen a #

Applicative Gen Source # 
Instance details

Defined in Copilot.Core.Random.Gen

Methods

pure :: a -> Gen a #

(<*>) :: Gen (a -> b) -> Gen a -> Gen b #

liftA2 :: (a -> b -> c) -> Gen a -> Gen b -> Gen c #

(*>) :: Gen a -> Gen b -> Gen b #

(<*) :: Gen a -> Gen b -> Gen a #

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 #

incDepth :: Gen a -> Gen a Source #