Reputation: 592
This is a guess number code. when I run it, I got an error : could not find the module 'Random'. what should I do ?
module Main where
import IO
import Random
main = do
hSetBuffering stdin LineBuffering
num <- randomRIO (1::Int, 100)
putStrLn "I'm thinking of a number between 1 and 100"
doGuessing num = do
putStrLn "Enter your guess:"
guess <- getLine
let guessNum = read guess
if guessNum < num
then do putStrLn "Too Low!"
doGuessing num
else if guessNum > num
then do putStrLn "Too High"
doGuessing num
else do putStrLn "You Win!"
Upvotes: 3
Views: 3698
Reputation: 47392
You should be using
import System.IO
import System.Random
instead.
Upvotes: 5
Reputation: 12457
Install random
package. The easiest way to do this is to use cabal
cabal install random
Upvotes: 1