
I havent done much IO at all in haskell, only within the function itself. However I want to get the input from the interface for the function and havent done this before. In my main function, I want to ask the user what they would like to do 'become fan' for example, then with their choice initiate the function and ask for the appropriate input for that function. This is the code below: 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 []) Say they choose film in a given year function function: filmsInGivenYear :: Int -> [Film] -> [String] filmsInGivenYear filmYear films = [ title | (Film title director year fans) <- films, year == filmYear] I need to ask the user what filmYear they want to insert. But i need to do this from the main function...I chose to do an if statement to choose what function they want, but i dont know where to go from there? any help will be greatly appreciated. thanks apple -- View this message in context: http://www.nabble.com/IO-help-tp23423403p23423403.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

I have a suggestion. Why don't you grab some introductory book on Haskell and learn Haskell syntax a little? applebiz89 wrote on 07.05.2009 13:46:
I havent done much IO at all in haskell, only within the function itself. However I want to get the input from the interface for the function and havent done this before.
In my main function, I want to ask the user what they would like to do 'become fan' for example, then with their choice initiate the function and ask for the appropriate input for that function. This is the code below:
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 What exactly do you think this line is going to do?
(if input == 1 then main x = insertFilm [] else if input == 2 then main x = becomeFan [] else if input == 3 then main x = numberOfFans []) All these "main x =" are just syntax errors.
Say they choose film in a given year function function:
filmsInGivenYear :: Int -> [Film] -> [String] filmsInGivenYear filmYear films = [ title | (Film title director year fans) <- films, year == filmYear]
I need to ask the user what filmYear they want to insert. But i need to do this from the main function...I chose to do an if statement to choose what function they want, but i dont know where to go from there?
any help will be greatly appreciated.
thanks
apple

Hello applebiz89, Thursday, May 7, 2009, 1:46:34 PM, you wrote:
main :: IO()
you may find http://haskell.org/haskellwiki/IO_inside interesting -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Have a look at the wikibook: http://en.wikibooks.org/wiki/Haskell/Simple_input_and_output Am 07.05.2009 um 11:46 schrieb applebiz89:
I havent done much IO at all in haskell, only within the function itself. However I want to get the input from the interface for the function and havent done this before.
In my main function, I want to ask the user what they would like to do 'become fan' for example, then with their choice initiate the function and ask for the appropriate input for that function. This is the code below:
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 [])
Say they choose film in a given year function function:
filmsInGivenYear :: Int -> [Film] -> [String] filmsInGivenYear filmYear films = [ title | (Film title director year fans) <- films, year == filmYear]
I need to ask the user what filmYear they want to insert. But i need to do this from the main function...I chose to do an if statement to choose what function they want, but i dont know where to go from there?
any help will be greatly appreciated.
thanks
apple -- View this message in context: http://www.nabble.com/IO-help- tp23423403p23423403.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (4)
-
Adrian Neumann
-
applebiz89
-
Bulat Ziganshin
-
Miguel Mitrofanov