module BirthdayLibrary =
type Birthday =
{ day :int
month :int }
module DataGen =
let birthdayGenerator (months:option<list<int>>) =
let monthGen = match months with
| Some m -> Gen.elements m
| None -> FsCheck.Gen.choose(1,12)
(fun m d -> { day = d
month = m}:BirthdayLibrary.Birthday)
<!> monthGen
<*> FsCheck.Gen.choose(1,28)
//I want this to have the signature Gen<BirthdayLibrary.Birthday list>
let oneForEveryMonthGen =
[ for m in [1 .. 12] ->
(fun mo -> birthdayGenerator (Some [mo]))]
Lets say I have something like the above. I have a birthday generator with the return type of Gen<BirthdayLibrary.Birthday>. You can optionally specify the month. What is the best way to go from a Gen<a> to a Gen<a list> WHILE specifying some constraint to item in the list's gen? I can think of ways to get <Gen<a> list>, which I don't think would work for composing a parent object that should contain a <list a> (which is the basis for this example). I can also think of a way to do Gen<Gen<a> list>, which I had composition problems with as well as all values in the list being the same. I saw Gen.arrayOf bit I can't think of how to get it to work with values for each item in the array.