[Haskell-cafe] How to write such a code elegantly ?
Ivan Lazar Miljenovic
ivan.miljenovic at gmail.com
Mon Jan 10 03:32:24 CET 2011
On 10 January 2011 12:25, z_axis <z_axis at 163.com> wrote:
>
> thanks for all of your replies. I will test your code later. Another newbie
> question is why has the following code indentation problem ?
>
> rollDice n = do
> let myGen =
> if doesFileExist "/dev/urandom"
> then betterStdGen
> else (mkStdGen . fromInteger) <$> picoSec
> return $ (take 1 $ randomRs (1,n) myGen) !! 0
I don't see an indentation problem, but I _do_ see a type problem:
doesFileExist presumably uses IO, and as such can't be used as a Bool
for the if statement.
--
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com
More information about the Haskell-Cafe
mailing list