[Haskell-cafe] Random Numbers for the beginner ?

Jon Cast jcast at ou.edu
Tue Jul 6 15:36:41 EDT 2004


sholderm at students.cs.uu.nl wrote:
<snip>
> Use
> 
>   (getStdRandom (randomR (1,6))) :: IO Int 

This much is fine, but...

> instead.
> 
> \begin{code}
> module Main where
> import Random
> 
> 
> main :: IO ()
> main =  do n <- (getStdRandom (randomR (1,6))) :: IO Int
>          ; print n
> \end{code}

Layout error: the semicolon must be indented further than the `n' is.
Furthermore, the semicolon is unnecessary; if it's deleted, yielding

> main :: IO ()
> main =  do n <- (getStdRandom (randomR (1,6))) :: IO Int
>            print n

the code works just fine.

Jon Cast



More information about the Haskell-Cafe mailing list