[Haskell-cafe] How to write such a code elegantly ?
Ivan Lazar Miljenovic
ivan.miljenovic at gmail.com
Mon Jan 10 01:51:39 CET 2011
On 10 January 2011 10:44, z_axis <z_axis at 163.com> wrote:
>
> betterStdGen :: IO StdGen
> betterStdGen = alloca $ \p -> do
> h <- openBinaryFile "/dev/urandom" ReadMode
> hGetBuf h p $ sizeOf (undefined :: Int)
> hClose h
> mkStdGen <$> peek p
Maybe use a catch or something here and have it return "IO (Maybe
StdGen)", with Nothing denoting that file not existing?
--
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com
More information about the Haskell-Cafe
mailing list