[Haskell-cafe] proper way to generate a random data in criterion
johan.tibell at gmail.com
Wed Oct 19 22:13:04 CEST 2011
On Wed, Oct 19, 2011 at 12:21 PM, Gregory Collins
<greg at gregorycollins.net>wrote:
> On Wed, Oct 19, 2011 at 5:03 PM, Johan Tibell <johan.tibell at gmail.com>
> > It does. You need to use evaluate to have ensure actually be evaluated.
> I'm almost certain you're wrong about this. The bang pattern on the
> return from ensure (!r1 <- ensure $ ...) forces r1 to WHNF, which goes
> through deepseq, and thus the whole list is forced. See
> https://gist.github.com/1299380 for a short counterexample.
I should have paid more attention; I missed the bangs on the bindings.
I still recommend the pattern I linked in my previous email. If you want to
do it they way you currently do use
let !foo = xs `deepseq` xs
no return needed.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe