FComp-1.0.2: Compose music

Safe HaskellNone
LanguageHaskell98

HarmTrace.Models.Generator

Synopsis

Documentation

class Generate a where Source

Methods

gen' :: FrequencyTable -> Int -> Int -> Maybe (Gen a) Source

Instances

Generate U 
GenerateG a => Generate (Var a) 
GenerateG a => Generate (Rec a) 
(Generate a, ConNames a, Generate b, ConNames b) => Generate ((:+:) a b) 
(Generate a, Generate b) => Generate ((:*:) a b) 
Generate (CEq k k c p q a) 
Generate a => Generate (CEq k k c p p a) 

genGdefault :: (Representable a, Generate (Rep a)) => FrequencyTable -> Int -> Maybe (Gen a) Source

Generic arbitrary function, sized and with custom constructor frequencies. This function does not require any particular nesting order of the sums of the generic representation.

arbitrary :: (Representable a, Generate (Rep a)) => Gen a Source

Generic arbitrary function with default sizes and constructor frequencies.

data Gen a :: * -> *

type FrequencyTable = [(String, Int)] Source

A frequency table detailing how often certain constructors should be picked. The String corresponds to the constructor name.

frequency :: [(Int, Gen a)] -> Gen a

Chooses one of the given generators, with a weighted random distribution. The input list must be non-empty.