[Haskell-cafe] Main function error

applebiz89 applebiz89 at hotmail.com
Tue May 12 12:59:47 EDT 2009

I have compiled each function independently and they have compiled the only
problem is the main function..

I keep getting the error 'films not defined' and I am not sure why


type Title = String
type Director = String
type Year = Int
type Fan = String

data Film = Film Title Director Year [Fan] deriving Show
-- List of films

testDatabase :: [Film]
testDatabase = [ (Film "Casino Royale" "Martin Campbell" 2006 ["Garry",
"Dave", "Zoe"])]

-- Function 

filmsInGivenYear :: Year -> [Film] -> [String]
filmsInGivenYear year' films = [ title | (Film title director year fans) <-
films, year == year']

doFilmsInGivenYear :: [Film] -> IO ()
doFilmsInGivenYear films  = do putStrLn "which year?"
                               text <- getLine
                               let year' = read text :: Int
                               let answer = filmsInGivenYear year' films
                               print answer

main :: IO ()
main = do 
         doFilmsInGivenYear films


if the other functions are compiling without this error im not sure as to
why the main function does not compile because of the films...any light on

View this message in context: http://www.nabble.com/Main-function-error-tp23506481p23506481.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.

More information about the Haskell-Cafe mailing list