betterStdGen :: IO StdGen betterStdGen = alloca $ \p -> do h <- openBinaryFile "/dev/urandom" ReadMode hGetBuf h p $ sizeOf (undefined :: Int) hClose h mkStdGen <$> peek p
picoSec :: IO Integer picoSec = do t <- ctPicosec `liftM` (getClockTime >>= toCalendarTime) return t The pseudo-code is : if doesFileExist "/dev/urandom" then myGen = betterStdGen else myGen = (mkStdGen . fromTnteger) <$> picoSec How to write these pseudo-code elegantly ? Sincerely! ----- e^(π.i) + 1 = 0 -- View this message in context: http://haskell.1045720.n5.nabble.com/How-to-write-such-a-code-elegantly-tp3334329p3334329.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe