[Haskell-cafe] Main function error
John Van Enk
vanenkj at gmail.com
Tue May 12 18:10:14 EDT 2009
What would you expect the program to output? You probably mean
'testDatabase' instead of 'films'.
On Tue, May 12, 2009 at 12:59 PM, applebiz89 <applebiz89 at hotmail.com> wrote:
> 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:
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe