J.L
J.L

Reputation: 592

Haskell Could not find module 'Random' when running GHCI, what should I do

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

Answers (2)

Chris Taylor
Chris Taylor

Reputation: 47392

You should be using

import System.IO
import System.Random

instead.

Upvotes: 5

Anton Guryanov
Anton Guryanov

Reputation: 12457

Install random package. The easiest way to do this is to use cabal

cabal install random

Upvotes: 1

Related Questions