On 10.02.2012 18:38, Yves Parès wrote:
I just thought about something: basically all these APIs provides a "IO
[a]" (where a is a randomly generable type) function.
Is there a problem with the approach that is to rely on lazy evaluation
to pass to pure code (either explicitely or through State) the infinite
list generated in IO and consume its head each time we need a random value?
Because there is no issue such as resource holding, like in the case of
file reading and enumerators, which would make lazy IO a not so good
approach...


It's more like "Seed → [a]". IO is not really needed here. I can see
following problems. None are real showstoppers (except maybe 2)


1. One may want to generate values of different types and/or
   distibutions. This is easily solved by state monad. But I can't
   see advantage over wrapped ST.

2. No way to make snapshot of generator state.

3. Laziness overhead. It may be significant if you try to sqeeze last
   bit of performance.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to