[Haskell-cafe] haskell - main function
rendel at cs.au.dk
Sat May 9 16:18:41 EDT 2009
> becomeFan :: Title -> fanName -> [Film] -> [Film]
> becomeFan _ _  = 
> becomeFan Title fanName ((Film Title Director Year fan):xs)
> | filmName == title = (Film Title Director Year fanName:fan) : xs
> | otherwise = (Film Title Director Year fan) : becomeFan Title fanName xs
In the type signature, you have to use types. In other words, use "Fan"
instead of "fanName" in the first line.
Variables have to begin with a lowercase letter. In other words, use
"title", "director", "year" instead of "Title", "Director", "Year".
Regarding the IO: I still propose to get your pure functions to work
first, then worry about IO. You can test your code by loading it into ghci.
> ghci nameofmyfile.hs
If everything works (i.e. no compile errors), you can call your
functions at the prompt:
> becomeFan "Casine Royale" "apple", testDatabase
Now ghci should answer with something like the following:
[(Film "Casino Royale" "Martin Campbell" 2006
["apple", "Garry", "Dave", "Zoe"])]
This way, you can test your stuff while working on it.
More information about the Haskell-Cafe