
5 Feb
2010
5 Feb
'10
8:39 a.m.
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