On Wed, May 6, 2009 at 4:27 PM, applebiz89 <[email protected]> wrote: > > main :: IO() > do putStr "Hi there! what is your name: " > fanName = getLine > do putStr "1 = Insert film, 2 = Become a Fan, 3 = The number of fans of a > film, 4 = Film released in a year: " > input = getLine > read input :: Int > (if input == 1 then main x = insertFilm [] else if input == 2 then main x = > becomeFan [] else if input == 3 then main x = numberOfFans []) > > // I thought using the if statement would work, but now I cant think how to > gather the needed input for the function they have chosen? Well, here input is a String. Type of read is read :: (Read a) => String -> a i.e. If a is an instance of the read class, read will be able to produce a value of type a given a String.
So you have to do something like x = read input :: Int read input will not destructively convert the type of input to int Alsom I think case x of will be better than if x = 1... --- Ashok `ScriptDevil` Gautham _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
