
Hi everyone, Using random numbers in Haskell is not entirely trivial (at least, still not for me) and again I am bagging my head against the Gen-Monad. I'd like to write a kind of bootstrap function sample :: Int -> [a] -> [a] sample n xs = ... that samples uniformly n elements from the list xs. I am not sure how to go about this. Would you try something like sample1 :: StdGen -> Int -> [a] -> [a] and later use this in an IO Monad, something along the lines of: do {g <- mkStdGen; return $ sample g n xs}, or would you write it like sample2 :: Int -> [a] -> Gen [a] and then use a function from QuickCheck like `generate` to get your samples? You see, I don't even know how to start thinking about the problem. If anyone got an idea, I'd be pleased if you could help me. Cheers, Thomas