I would like to generate an arbitrary (large) value to benchmark the performance of constructing that value with isomorphic types. It seems like QuickCheck might be useful in this regards. Has anyone done something similar?<br>

<br>In versions 1.*, there was a generate function:<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">generate :: Int -&gt; StdGen -&gt; Gen a -&gt; a<br>

generate n rnd (Gen m) = m size rnd&#39;<br>   where (size, rnd&#39;) = randomR (0, n) rnd<br></blockquote><br>That seems to have disappeared in versions 2.*, and I didn&#39;t find a clear replacement. I came up with using the destructor for Gen:<br>

<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">unGen :: Gen a -&gt; StdGen -&gt; Int -&gt; a<br></blockquote><br>The function generate seems to have a little something extra, though I&#39;m not sure if it&#39;s necessary. Is this true, or should I write an equivalent generate function? As an aside, it would be nice to have a generate function in the library, even if it is only a wrapper for unGen.<br>

<br>In the end, I would write something like the following:<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">unGen arbitrary (mkStdGen 11) 5 :: [Int]<br>

</blockquote><br>This produces, for example, [5,1,-2,-4,2]. I also want to generate the same value for a type isomorphic to [Int].<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">

unGen arbitrary (mkStdGen 11) 5 :: List Int<br></blockquote><br>Unfortunately, this produces Cons 4 (Cons 3 (Cons (-2) (Cons 0 (Cons (-1) Nil)))): same length but different values. The Arbitrary instances are the same. I had similar results with generate from QC 1.<br>

<br>Any suggestions on how to do this? With another library perhaps?<br><br>Thanks,<br>Sean<br>