[Haskell-beginners] (no subject)
Ashley Banks
applebiz89 at hotmail.com
Wed May 6 09:28:18 EDT 2009
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.
// Say I have this as my data type and list of films
data Film = Film String String Int [String]
-- List of films
testDatabase :: [Film]
testDatabase = [(Film "Casino Royale" "Martin Campbell" 2006 ["Garry",
"Dave", "Zoe"]) ]
// with functions such as:
becomeFan :: String -> String -> [Film] -> [Film]
becomeFan _ _ [] = []
becomeFan filmName fanName ((Film title director year fans):xs)
| filmName == title = (Film title director year fanName:fans) : xs
| otherwise = (Film title director year fans) : becomeFan filmName fanName
xs
filmsInGivenYear :: Int -> [Film] -> [String]
filmsInGivenYear filmYear films = [ title | (Film title director year fans)
<- films, year == filmYear]
// I want to ask the user what function they want to use, I have this so far
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?
thanks
apple
_________________________________________________________________
Beyond Hotmail — see what else you can do with Windows Live.
http://clk.atdmt.com/UKM/go/134665375/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20090506/1a624f35/attachment.htm
More information about the Beginners
mailing list