[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'.
/jve
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
>
> [code]
>
> 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
> main
>
> [/code]
>
> 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
> this?
>
> Thanks
> --
> 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.
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090512/fcddf5f4/attachment.html
More information about the Haskell-Cafe
mailing list