Martijn,

Ryan wrote:

Unfortunately, this makes things like
infinite_xs <- sequence (repeat arbitrary)
no longer work, since the state never comes out the other side.

You replied:

You're asking to execute an infinite number of monadic actions. How can this ever terminate at all?

There is this thing called lazy evaluation, you know. ;-)

Try for yourself:

  import System.Random
  import Test.QuickCheck

  foo :: Gen [Int]
  foo = do
    ns <- sequence (repeat arbitrary)
    return (take 5 ns)

  main ::       IO ()
  main = do
    stdGen <- newStdGen
    print (generate 42 stdGen foo)

Cheers,

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

Reply via email to