
17 Mar
2008
17 Mar
'08
8:47 a.m.
2008/3/16 Sebastian Sylvan
featureGenNormal = do id <- stringGen name <- stringGen featuretype <- arbitrary grouptype <- arbitrary children <- arbitrary properties <- listGen stringGen return (Feature id name featuretype grouptype children properties)
Note that we use "arbitrary" to generate the list of children recursively.
Also, you can shorten this significantly with liftM or ap (from Control.Monad):
featureGenNormal = liftM6 Feature stringGen stringGen arbitrary arbitrary arbitrary (listGen stringGen) featureGenNormal = return Feature `ap` stringGen `ap` stringGen `ap` arbitrary `ap` arbitrary `ap` listGen stringGen