
Hi, thank you . I read your souce, I found the depth is only 2, right? like data A = [A]|String, any easy way to control the maximum_depth of generated data? Regards,bob 于 11-7-17 下午8:13, Ivan Lazar Miljenovic 写道:
On 17 July 2011 23:42, bob zhang
wrote: Hi, all, I found derive + quickCheck very useful but I came across some problems. I used derive to derive instance of Arbitrary immeditaely, but sometimes the sample is non-terminating, which I mean the result is very very big.
[snip]
data JValue = JString String | JNumber Double | JBool Bool | JNull | JObject [(String, JValue)] -- | JArray [JValue] -- deriving (Eq,Ord,Show) $(derive makeArbitrary ''JValue) Your JValue type is recursive; as such I highly suggest you manually create the Arbitrary instances for it (e.g. a helper function with a Bool parameter to indicate whether or not to create recursive calls; see how I do it in http://code.haskell.org/graphviz/Data/GraphViz/Testing/Instances/Canonical.h... where the DotStatements type can have DotSubGraph values, which in turn have DotStatements).