On Fri, 13 Jun 2008, Stephen Howard wrote:

Hi List,

I am a newcomer doing my obligatory struggling with Haskell's type system, and I've got a nut I've not been able to crack. Given:

import Random

random_test :: Int -> String
random_test n = do
  g <- getStdGen
  take n (randoms g)::String

I'm expecting that I ought to be able to pass this action an integer and get back a random string that long (given, not all characters may be printable).

If you only need an arbitrary sequence and it is ok for you to get always the same one, you can construct a random generator using mkStdGen.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to