Haskellで乱数は使ったことなかったのでちょっと試しに書いてみた。

module MyRandom where
import System.Random
import System.Time
import System.IO.Unsafe

getPicosec :: IO Integer
getPicosec = getClockTime >>= return . ctPicosec . toUTCTime

newStdGenFromClock :: IO StdGen
newStdGenFromClock = getPicosec >>= return . mkStdGen . fromInteger

randomsRIO :: Random a => (a, a) -> IO [a]
randomsRIO = (newStdGenFromClock >>=) . (return .) . randomRs
-- randomsRIO r = newStdGenFromClock >>= return . randomRs r

randomsIO :: Random a => IO [a]
randomsIO = newStdGenFromClock >>= return . randoms

randomsRUnsafe :: Random a => (a, a) -> [a]
randomsRUnsafe = unsafePerformIO . randomsRIO

randomsUnsafe :: Random a => [a]
randomsUnsafe = unsafePerformIO randomsIO


これをインポートして take 10 $ randomsRUnsafe (0, 5) とかすれば乱数リストが取れた。